Tag: server

Invalid byte sequence in US-ASCII (ArgumentError) with Ruby on Rails

Lately when starting Unicorn instances, I've encountered following issue:

$ bundle exec unicorn_rails -c config/unicorn.rb -E production -D
/gems_path/lib/bundler.rb:294:in `block in load_gemspec_uncached': 
  invalid byte sequence in US-ASCII (ArgumentError)
	from /gems_path/lib/bundler.rb:291:in `chdir'
	from /gems_path/lib/bundler.rb:291:in `load_gemspec_uncached'
	from /gems_path/lib/bundler.rb:282:in `load_gemspec'
	from /gems_path/lib/bundler/source.rb:411:in `block in load_spec_files'
	from /gems_path/lib/bundler/source.rb:410:in `each'
	from /gems_path/lib/bundler/source.rb:410:in `load_spec_files'
	from /gems_path/lib/bundler/source.rb:799:in `load_spec_files'
	from /gems_path/lib/bundler/source.rb:381:in `local_specs'
	from /gems_path/lib/bundler/source.rb:774:in `specs'
	from /gems_path/lib/bundler/lazy_specification.rb:53:in `__materialize__'
	from /gems_path/lib/bundler/spec_set.rb:86:in `block in materialize'
	from /gems_path/lib/bundler/spec_set.rb:83:in `map!'
	from /gems_path/lib/bundler/spec_set.rb:83:in `materialize'
	from /gems_path/lib/bundler/definition.rb:113:in `specs'
	from /gems_path/lib/bundler/definition.rb:158:in `specs_for'
	from /gems_path/lib/bundler/definition.rb:147:in `requested_specs'
	from /gems_path/lib/bundler/environment.rb:23:in `requested_specs'
	from /gems_path/lib/bundler/runtime.rb:11:in `setup'
	from /gems_path/lib/bundler.rb:116:in `setup'
	from /gems_path/lib/bundler/setup.rb:7:in `<top (required)>'
	from /gems_path/rubygems/custom_require.rb:36:in `require'
	from /gems_path/rubygems/custom_require.rb:36:in `require'

There are two ways to fix this. You can export language settings to your shell:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

or you can put this into your Gemfile:

if RUBY_VERSION =~ /1.9/
  Encoding.default_external = Encoding::UTF_8
  Encoding.default_internal = Encoding::UTF_8
end

Both methods should work.

No source for ruby-1.9.3-p374 provided with debugger-ruby_core_source gem

After updating Ruby to 1.9.3-374 debugger stopped working:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/mencio/.rvm/rubies/ruby-1.9.3-p374/bin/ruby extconf.rb 
checking for vm_core.h... no
checking for vm_core.h... no
Makefile creation failed
**************************************************************************
No source for ruby-1.9.3-p374 provided with debugger-ruby_core_source gem.
**************************************************************************
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
	--with-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/home/mencio/.rvm/rubies/ruby-1.9.3-p374/bin/ruby
	--with-ruby-dir
	--without-ruby-dir
	--with-ruby-include
	--without-ruby-include=${ruby-dir}/include
	--with-ruby-lib
	--without-ruby-lib=${ruby-dir}/lib


Gem files will remain installed in /path/gems/debugger-linecache-1.1.2 for inspection.
Results logged to /path/gems/debugger-linecache-1.1.2/ext/trace_nums/gem_make.out
An error occurred while installing debugger-linecache (1.1.2), and Bundler cannot continue.
Make sure that `gem install debugger-linecache -v '1.1.2'` succeeds before bundling.

How can we fix this?

gem install debugger-linecache -v '1.1.2' -- --with-ruby-include=\$rvm_path/src/ruby-1.9.3-p374

And that's all!

Copyright © 2024 Closer to Code

Theme by Anders NorenUp ↑