pry-rails: Encoding::UndefinedConversionError
When I paste “ñ” (with quotes) in to the console with pry-rails (0.3.3) enabled I will get an Encoding::UndefinedConversionError error.
$ bundle exec rails console
main:0>"��"
/Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/history.rb:106:in `write': "\xC3" from ASCII-8BIT to UTF-8 (Encoding::UndefinedConversionError)
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/history.rb:106:in `puts'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/history.rb:106:in `save_to_file'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/history.rb:50:in `call'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/history.rb:50:in `push'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_instance.rb:267:in `handle_line'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_instance.rb:243:in `block (2 levels) in eval'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_instance.rb:242:in `catch'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_instance.rb:242:in `block in eval'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_instance.rb:241:in `catch'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_instance.rb:241:in `eval'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/repl.rb:77:in `block in repl'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/repl.rb:67:in `loop'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/repl.rb:67:in `repl'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/repl.rb:38:in `block in start'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `call'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/input_lock.rb:61:in `__with_ownership'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/input_lock.rb:79:in `with_ownership'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/repl.rb:38:in `start'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/repl.rb:15:in `start'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/pry-0.10.1/lib/pry/pry_class.rb:169:in `start'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/commands/console.rb:47:in `start'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/commands/console.rb:8:in `start'
from /Users/lukec/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/railties-3.2.21/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
If I disable pry-rails in my Gemfile I get the expected output.
$ bundle exec rails console
Loading development environment (Rails 3.2.21)
irb(main):001:0> "ñ"
=> "ñ"
I’d love to get to the bottom of this, so please let me know if there’s any additional information I can provide.
About this issue
- Original URL
- State: open
- Created 9 years ago
- Comments: 18 (1 by maintainers)
http://altarf.net/computer/rails/3222
add
~/.pryrcwith contentand it works for me.
Had same error on Linux in Docker image. Problem was in system locale settings (it was set to
POSIX).Fixed by setting locale to Unicode-enabled one:
In your local system check output of
localecommand and addexport LANG=C.UTF-8 LC_ALL=C.UTF-8to your~/.bashrcor~/.zshrcif necessaryI’ve solved this. refer to pry/pry#230420454
I was able to “fix” this by adding this line in:
/Users/<username>/.rvm/gems/ruby-2.7.5/gems/pry-0.13.1/lib/pry/history.rbOf course the issue is still there, so I opened an issue in RbReadline (see https://github.com/ConnorAtherton/rb-readline/issues/163)
Removing rb-readline solved the issue for me.
+1
+1
+1