R
R
rusher2014-12-19 11:50:50
Ruby on Rails
rusher, 2014-12-19 11:50:50

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

The following error occurs in the net-ssh-2.9.1 gem, the method is called with a parameter, if the parameter is less than 12 characters (rus), then everything works fine, if an error occurs more, or 23 characters in Latin norms, and more is an error. Inside the method code, string concatenation and command call via net-ssh. If you comment out the use of Net::ssh, the error does not occur. Prior to invoking the Net::ssh command, the command is prepared in the command line by concatenation with the received parameter.
a piece of code that rails swears at

# 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'

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question