Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 1.9: ArgumentError: invalid byte sequence in US-ASCII #9

Closed
janreges opened this issue May 1, 2015 · 10 comments
Closed

Ruby 1.9: ArgumentError: invalid byte sequence in US-ASCII #9

janreges opened this issue May 1, 2015 · 10 comments
Milestone

Comments

@janreges
Copy link

janreges commented May 1, 2015

Hi,

when i installed airbrussh, my cap production deploy ends with trace below.

I tried to add #encoding: utf-8 into "deploy.rb", or add to LANG="en_US.UTF-8" and LC_ALL="en_US.UTF-8" into "Gemfile", but it doesn't help.

Thank you for your suggestions, how to fix it.

cap aborted!
ArgumentError: invalid byte sequence in US-ASCII
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/trace_output.rb:16:in `block in trace_on'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/trace_output.rb:14:in `map'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/trace_output.rb:14:in `trace_on'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:376:in `trace'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:222:in `display_exception_message_details'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:209:in `display_exception_details'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:198:in `display_error_message'
/usr/local/lib64/ruby/gems/1.9.1/gems/capistrano-3.4.0/lib/capistrano/application.rb:73:in `display_error_message'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:185:in `rescue in standard_exception_handling'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:93:in `load_rakefile'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:77:in `block in run'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/usr/local/lib64/ruby/gems/1.9.1/gems/capistrano-3.4.0/lib/capistrano/application.rb:15:in `run'
/usr/local/lib64/ruby/gems/1.9.1/gems/capistrano-3.4.0/bin/cap:3:in `<top (required)>'
/usr/local/bin/cap:23:in `load'
/usr/local/bin/cap:23:in `<main>'
@janreges
Copy link
Author

janreges commented May 1, 2015

Btw, also this in begin of Gemfile doesn't help ;-(

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

@mattbrictson
Copy link
Owner

Thanks for the bug report! I'll investigate today.

@janreges
Copy link
Author

janreges commented May 1, 2015

Thank you, Matt.

@mattbrictson
Copy link
Owner

@janreges Can you try the latest commit on master (e5236dc) to see if it fixes the problem?

In your Gemfile:

gem "airbrussh", :github => "mattbrictson/airbrussh", :ref => "e5236dc", :require => false

@mattbrictson mattbrictson changed the title ArgumentError: invalid byte sequence in US-ASCII Ruby 1.9: ArgumentError: invalid byte sequence in US-ASCII May 1, 2015
@janreges
Copy link
Author

janreges commented May 2, 2015

@mattbrictson - i tried it, but it doesn't help :-(

After Gemfile update, i run bundle and bundle update. Gemfile.lock was updated and it contains:

GIT
  remote: git://github.com/mattbrictson/airbrussh.git
  revision: e5236dc4d4b7d45c8020536a105d834b3be45f3c
  ref: e5236dc
  specs:
    airbrussh (0.3.0)
      sshkit (>= 1.6.1, != 1.7.0)

and airbrussh! in section DEPENDENCIES.

Current trace is the same:

cap aborted!
ArgumentError: invalid byte sequence in US-ASCII
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/trace_output.rb:16:in `block in trace_on'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/trace_output.rb:14:in `map'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/trace_output.rb:14:in `trace_on'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:376:in `trace'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:222:in `display_exception_message_details'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:209:in `display_exception_details'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:198:in `display_error_message'
/usr/local/lib64/ruby/gems/1.9.1/gems/capistrano-3.4.0/lib/capistrano/application.rb:73:in `display_error_message'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:185:in `rescue in standard_exception_handling'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:93:in `load_rakefile'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:77:in `block in run'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/lib64/ruby/gems/1.9.1/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/usr/local/lib64/ruby/gems/1.9.1/gems/capistrano-3.4.0/lib/capistrano/application.rb:15:in `run'
/usr/local/lib64/ruby/gems/1.9.1/gems/capistrano-3.4.0/bin/cap:3:in `<top (required)>'
/usr/local/bin/cap:23:in `load'
/usr/local/bin/cap:23:in `<main>'

@mattbrictson
Copy link
Owner

@janreges The stack trace you posted is an error in Rake itself, which is making troubleshooting difficult. Rake seems to have caught an exception, but is encountering its own error when attempting to handle that exception. As a result, the original exception is getting lost.

Is there any way you could use a debugger, add some puts statements, or otherwise modify lib/capistrano/application.rb:73 so that we can see what the original exception is before it is handed off to Rake's display_error_message?

@janreges
Copy link
Author

janreges commented May 3, 2015

@mattbrictson: i'm not a ruby/rails programmer, but this was simple :)

I added puts ex.message into display_error_message in application.rb.

In deploy, an exception below has been thrown. After that, i looked into formatter.rb and i saw a problem. There was no # encoding: UTF-8 in the beginning, as you added in commit e5236dc.

When i added encoding manually, everything is working fine.

So, it's my fail. Probably still something else was needed, except Gemfile update and bundle + bundle update?

/usr/local/lib64/ruby/gems/1.9.1/gems/airbrussh-0.3.0/lib/airbrussh/formatter.rb:207: invalid multibyte char (US-ASCII)
/usr/local/lib64/ruby/gems/1.9.1/gems/airbrussh-0.3.0/lib/airbrussh/formatter.rb:207: invalid multibyte char (US-ASCII)
/usr/local/lib64/ruby/gems/1.9.1/gems/airbrussh-0.3.0/lib/airbrussh/formatter.rb:207: syntax error, unexpected $end, expecting ')'
        red("✘ #{number} #{user_at_host} (...
               ^
cap aborted!
invalid byte sequence in US-ASCII
cap aborted!
ArgumentError: invalid byte sequence in US-ASCII

@mattbrictson
Copy link
Owner

@janreges Great!

I think you did everything right, except maybe you ran just cap instead of bundle exec cap? The latter ensures that the version in the Gemfile is used when the airbrussh gem is loaded.

@mattbrictson
Copy link
Owner

Fixed in e5236dc.

@mattbrictson mattbrictson added this to the 0.4.0 milestone May 3, 2015
@janreges
Copy link
Author

janreges commented May 3, 2015

@mattbrictson Your guess was right :-) I ran "cap" instead of "bundle exec cap".

Thank you for your support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants