@rusher

Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8 в net-ssh?

Возникает следующая ошибка в геме net-ssh-2.9.1, вызов происходит метода с параметром, если параметр меньше 12 символов (рус) то нормально все работает, если больше возникает ошибка, либо 23 символа латиницей норм, а больше уже ошибка. Внутри кода метода конкатенация строк и вызов команды по net-ssh. Если закоментить использование Net::ssh ошибки не происходит. До вызова команды Net::ssh команда подготавливается в строке command путем конкатенации с полученным параметром.

кусок кода на которую ругается rails
# Writes the given data literally into the string. Does not alter the
    # read position. Returns the buffer object.
    def write(*data)
      data.each { |datum| @content << datum }
      self
    end


Encoding::CompatibilityError: incompatible character encodings: ASCII-8BIT and UTF-8
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/buffer.rb:284:in `block in write'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/buffer.rb:284:in `each'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/buffer.rb:284:in `write'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/buffer.rb:322:in `block in write_string'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/buffer.rb:319:in `each'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/buffer.rb:319:in `write_string'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/buffer.rb:55:in `block in from'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/buffer.rb:47:in `step'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/buffer.rb:47:in `from'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:470:in `send_channel_request'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:159:in `exec'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:330:in `block in exec'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `call'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/connection/channel.rb:514:in `do_open_confirmation'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:545:in `channel_open_confirmation'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/net-ssh-2.9.1/lib/net/ssh/connection/session.rb:465:in `dispatch_incoming_packets'
... 21 levels...
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:241:in `load'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:241:in `block in load'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:232:in `load_dependency'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:241:in `load'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/commands/rails.rb:6:in `call'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/command_wrapper.rb:38:in `call'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/application.rb:180:in `block in serve'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/application.rb:153:in `fork'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/application.rb:153:in `serve'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
        from /home/savvinovan/.rvm/gems/ruby-2.1.4/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
        from /home/savvinovan/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        from /home/savvinovan/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  • Вопрос задан
  • 2710 просмотров
Пригласить эксперта
Ответы на вопрос 1
@rusher Автор вопроса
решилось добавлением force_encoding('binary') на все переданные переменные в самом методе
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы