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

readline support not guaranteed without rb-readline #118

Closed
cainlevy opened this issue Feb 8, 2015 · 15 comments
Closed

readline support not guaranteed without rb-readline #118

cainlevy opened this issue Feb 8, 2015 · 15 comments

Comments

@cainlevy
Copy link

cainlevy commented Feb 8, 2015

problem:

On Ubuntu 14.04, if libreadline-dev is not installed prior to using rbenv to compile ruby, then readline will not be available:

$ irb
irb(main):001:0> require 'byebug'
LoadError: cannot load such file -- readline

possible solutions:

  • update readme to advise ubuntu users to run sudo apt-get install libreadline-dev before rbenv install
  • add rb-readline as a dependency
@deivid-rodriguez
Copy link
Owner

Thanks for the report, I'll have a look and decide what to do.

@deivid-rodriguez
Copy link
Owner

@cainlevy Do you have any preferred solution for this? I think the better way would be to add rb-readline as a dependency but I'm interested in your opinion.

@cainlevy
Copy link
Author

I'm not sure what the tradeoffs are, honestly. I tried to think of another popular REPL that might use readline and found this in Pry:

https://github.com/pry/pry/blob/5101cd4e34d905e10a218b01fb355668bf2fec21/lib/pry/config/default.rb#L150-L160

@deivid-rodriguez
Copy link
Owner

Let's find out! :)

@kamen-hursev
Copy link

The problem that @cainlevy describes is valid indeed with Ubuntu, however using rb-readline leads to other problems. For example pressing ctrl+left arrow results in ;5D instead of going to the beginning of the word. To be honest I couldn't really understand why this happens and how to fix it, and it was much easier to recompile ruby after installing libreadline-dev.

@deivid-rodriguez, I think a better solution will be adding a readme section or a descriptive error message, than depending on rb-readline when some of the users don't really need this gem.

@deivid-rodriguez
Copy link
Owner

@kamen-hursev Yep, I'm experiencing more problems than before after including rb-readline... :(

I'll remove it again and do what pry does (show a help message whenever requiring readline fails). And then release another minor version.

@knu
Copy link

knu commented Mar 16, 2015

After upgrading byebug I see many problems occur in a Pry session because of rb-readline, which seemingly cannot handle multi-byte characters properly. Literal strings containing multi-byte characters are now regarded as ASCII-8BIT instead of the default encoding (UTF-8), the multi-byte characters after colorization (syntax highlighting) are all garbled, and the terminal often gets stuck in a completely unusable state especially when pry enters a nested session. I've never seen these problems with the native readline library.
I'd really appreciate if this got reverted soon. 🙏

@deivid-rodriguez
Copy link
Owner

Done!

@knu
Copy link

knu commented Mar 17, 2015

Thanks! That saved me.

@jerefrer
Copy link

jerefrer commented Sep 8, 2015

@kamen-hursev I'm having the same issue about ctrl+left arrow resulting in 5D but without using rb-readline. I tried recompiling Ruby after rvm pkg install readline, I tried recompiling using rvm reinstall ruby-2.0.0-p643 -C --with-readline-dir=~/.rvm/usr/ but none of this worked. As you can see I'm using RVM, and I'm on Archlinux.

When using debugger there is no such issue.

Do you have any idea how to make it work ? I'm so used to those shortcuts to navigate through text that it's very frustrating ...

@kamen-hursev
Copy link

Sorry, @jerefrer, but I don't think I can help you with this. This issue was fixed with byebug.
It might be that you have rb-readline as dependency of another gem or you might try to install libreadline-dev with the package manager of the OS. I use rbenv with ruby-build and I'm not sure what is supposed to be done with rvm.

@pathann
Copy link

pathann commented Sep 27, 2015

@jerefrer with rvm and arch linux i got to work by simply installing gem rb-readline and adding it to the gemifle

@jerefrer
Copy link

@pathann Nope, doesn't work ... Thanks for trying :)
Which versions are you using ? (Ruby, Rails, Byebug, rb-readline, ...)

@mehta
Copy link

mehta commented Dec 6, 2016

To fix this (for OSX, tested on Sierra), run following command in your shell -

ln -s /usr/local/opt/readline/lib/libreadline.dylib /usr/local/opt/readline/lib/libreadline.6.dylib

@pancutan
Copy link

pancutan commented Jul 7, 2018

Thanks guys.
Provided solution of add rb-readline as dependency of pry-byebug, works also very well on Archlinux / Manjaro. I was worried because on this distros there are not readline-dev package as Ubuntu does.

Cheers up!

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

No branches or pull requests

8 participants