airbrussh icon indicating copy to clipboard operation
airbrussh copied to clipboard

LoadError in Airbrussh::Console#utf8_supported?

Open mike-stewart opened this issue 7 years ago • 2 comments

Using airbrussh 1.1.0 (w/ capistrano 3.6.0 and ruby 2.1.7), I intermittently get a LoadError printing certain non-ASCII text. Sometimes it prints OK, sometimes it blows up.

This is the backtrace for a string containing the Unicode character "𝄞" (U+1D11E):

LoadError: dlopen(enc/trans/single_byte.so, 9): image not found - enc/trans/single_byte.so
gems/airbrussh-1.1.0/lib/airbrussh/console.rb:83:in `encode'
gems/airbrussh-1.1.0/lib/airbrussh/console.rb:83:in `utf8_supported?'
gems/airbrussh-1.1.0/lib/airbrussh/console.rb:42:in `truncate_to_console_width'
gems/airbrussh-1.1.0/lib/airbrussh/console.rb:26:in `print_line'
gems/airbrussh-1.1.0/lib/airbrussh/console_formatter.rb:112:in `print_line'
gems/airbrussh-1.1.0/lib/airbrussh/console_formatter.rb:117:in `print_indented_line'
gems/airbrussh-1.1.0/lib/airbrussh/console_formatter.rb:42:in `block in log_command_data'
gems/airbrussh-1.1.0/lib/airbrussh/console_formatter.rb:41:in `each_line'
gems/airbrussh-1.1.0/lib/airbrussh/console_formatter.rb:41:in `log_command_data'
gems/airbrussh-1.1.0/lib/airbrussh/delegating_formatter.rb:25:in `public_send'
gems/airbrussh-1.1.0/lib/airbrussh/delegating_formatter.rb:25:in `block (3 levels) in <class:DelegatingFormatter>'
gems/airbrussh-1.1.0/lib/airbrussh/delegating_formatter.rb:25:in `map'
gems/airbrussh-1.1.0/lib/airbrussh/delegating_formatter.rb:25:in `block (2 levels) in <class:DelegatingFormatter>'

I fixed it by also rescueing LoadError here: https://github.com/mattbrictson/airbrussh/blob/master/lib/airbrussh/console.rb#L84

Any ideas on what could be going wrong here, or would you be open to a PR to add a rescue @mattbrictson?

mike-stewart avatar Jul 27 '16 23:07 mike-stewart

Thanks for the report!

My hunch is that this is a problem with your Ruby installation. I'd rather not add a rescue unless this problem is widespread. Can you see if there is a fix for your Ruby?

I found this, maybe it will help: http://stackoverflow.com/questions/13277729/ruby-loaderror-enc-trans-single-byte

mattbrictson avatar Jul 28 '16 00:07 mattbrictson

I looked at that earlier and tried the suggested solution of ensuring everything in ~/.rvm (I use RVM on OS X) was readable by my user. Also tried reinstalling my ruby. No dice.

I'll dig in some more and post here if I can find a solution.

mike-stewart avatar Jul 28 '16 14:07 mike-stewart