Can't enter Umlauts in Ruby 1.9.3 IRB - ruby

I am experiencing very strange behavior in Ruby 1.9.3's IRB with Mac OS 10.7.3
When I try to enter an Umlaut, it's escaped in the prompt and looks like this (I entered "ΓΌ" on the keyboard)
irb(main):001:0> "\U+FFC3\U+FFBC"
What's super strange is this:
irb(main):001:0> "\U+FFC3\U+FFBC".length
=> 0
Of course, the character isn't displayed either:
irb(main):001:0> "\U+FFC3\U+FFBC"
=> ""
Does anyone know what's going on here or how to fix this?

Victor Moroz didn't quite give the definitive answer but his link led me to a solution (thx!):
I forgot to mention:
Im running homebrew
I built ruby using ruby-build and this recipe (1.9.3-p125-perf, with falcon patches)
What I then did to solve this problem in my case was to recompile, this time pointing ruby to a more recent version of readline (6.2.2 in my case) that I installed with homebrew.
The steps it took were:
$ brew install readline
$ export CPPFLAGS=-I/usr/local/Cellar/readline/6.2.2/include
$ export LDFLAGS=-L/usr/local/Cellar/readline/6.2.2/lib/
$ curl https://raw.github.com/gist/1688857/rbenv.sh | sh && rbenv global 1.9.3-p125-perf

I ran across this problem as well, but my Ruby was built with rvm rather than ruby-build. I'd also previously used Homebrew on Mountain Lion to run other package installers, and among them got Readline 6.2.5 or something like that. This turns out to be the cause of this issue for me. So here's the fix:
From the RVM site:
If you have an error when compiling pertaining to readline, you may need to attempt installing with the procedure defined below.
$ rvm pkg install readline
$ rvm reinstall 1.9.2 --with-readline-dir=$rvm_path/usr
Note that this error occurs most often when having a MacPorts, Fink, or Homebrew installed readline on your system.
Hope this helps someone else!

This may help http://henrik.nyh.se/2008/03/irb-readline
UPDATE In fact on my Mac I have no problem with port version of Ruby, but original Mac OS version does have this problem (never used that one). So the easiest way is probably just to install Ruby from ports.

this command solved it for me:
brew install readline
RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 1.9.3-p286
source: https://github.com/rbenv/ruby-build/wiki

Related

Ruby Gems suddenly stopped working on ubuntu 12.04

After a couple of days of not doing pretty much anything on the ubuntu box, I decided to try out some ruby stuff. For this, I wanted to fire up pry. Unfortunately, I was presented with
Sorry, you can't use Pry without Readline or a compatible library.
Please gem install rb-readline or recompile Ruby --with-readline.
~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in
`require': libreadline.so.5: cannot open shared object file: No such
file or directory -
~/.rbenv/versions/2.1.1/lib/ruby/2.1.0/x86_64-linux/readline.so
(LoadError)
Being quite new to linux in general, I figured I'd just do as it said, and install this rb-readline. The installation passes just fine, but doesnt seem to do anything at all. If I do gem list p, the package just doesn't appear.
So yeah, I just don't know what to do to get it working again, and the only thing I managed to find by searching was related to an installation without rbenv and had something to do with sudo etc.
Any ideas?
Without understanding the problem and following the advice in option 2 of the message:
Sorry, you can't use Pry without Readline or a compatible library.
Possible solutions:
* Rebuild Ruby with Readline support using `--with-readline`
* Use the rb-readline gem, which is a pure-Ruby port of Readline <==== Option 2
* Use the pry-coolline gem, a pure-ruby alternative to Readline
I added the gem into the Gemfile (as follows), bundled and pry was then available.
group :development, :test do
gem 'pry'
gem 'rb-readline'
end
I had this problem too. I am using rbenv and reinstalling ruby via
rbenv install -f 2.2.3
did fixed it for me. Of course you'd put in your respective version. -f forces the installation even though you already have that specific version installed. use rbenv global to find out what version you have installed and set.
I have some problem. But I don't want to add gem 'rb-readline'. So try it...
$ln -s /usr/local/opt/readline/lib/libreadline.8.0.dylib /usr/local/opt/readline/lib/libreadline.7.dylib
Do a sudo apt-get install libreadline-dev, seems like you're missing the readline shared library that pry is wanting. If it worked before, not sure why the library isn't there anymore.
I ended up doing rbenv uninstall, followed by rbenv install and re-installing all the gems, and got it back to working. Still no idea what caused it in the first place, but it works now.

Cannot port install Ruby

I am having trouble installing ruby through mac ports. The error that I am receiving is this one:
:error:extract org.macports.extract for port ruby returned: command execution failed
:debug:extract Error code: NONE
:debug:extract Backtrace: command execution failed
while executing
"$procedure $targetname"
:info:extract Warning: targets not executed for ruby: org.macports.activate
Can anyone help with this error? So far I have tried doing:
port -v selfupdate
xcodebuild -license agree
Neither of those seemed to fix my target issue.
Anyone have other tips?
I am not experienced using macports, and would rather prefer homebrew over it, at the moment.
However, to install Ruby (or specific versions of Ruby), I would really recommend using rbenv or RVM.
It seems that you are new to ruby, and if that is the case, I would further advice you to use rbenv over RVM. You will find it more pleasant, at the moment. Just my 2 cents.
To fix this problem what I had to do was go to the MacPorts webpage, download the new Mavericks MacPorts package, and run through that installation. I thought that doing a port -v selfupdate would update my current MacPorts to the Mavericks OS MacPorts but unfortunately it did not.

Best way to update Ruby to the latest 1.9 version on OS X?

Does Mac OS X support ruby version 1.9.+? Is it recommended to update to 1.9 or should I wait?
The reason I ask is because I'm trying to use some plugins that only support Ruby 1.9+
Most people use RVM to install Ruby on the mac. Basically it allows you to have multiple versions of ruby installed on the same machine and to switch between them at will. You can also install gems on a project by project basis rather than installing them all globally using sudo like you probably do now.
You can install RVM by running
bash < <(curl -s https://rvm.ioinstall/rvm)
in terminal (assuming you have git installed). Full installation instructions can be found on the RVM site.
Here is a tutorial which I personally found invaluable when getting used to using RVM in my workflow at the start. It will probably help you too.
I wouldn't try to update the system Ruby, since OS X uses it for some stuff (I think). Instead, use RVM.
I won't recommend a "preferred" method, but just outline the possibilities:
Install ruby 1.9 from ports using port install ruby19 +nosuffix
Install using RVM as others suggested
Check out the stable version with svn, then
./configure --prefix=/opt/ruby --enable-shared
make && sudo make install
I prefer the third way, as it gives the most flexibility, and the latest stable version. Don't forget to add /opt/ruby/bin to path before everything else if you choose this path (no pun intended).
And as others said - don't touch the system ruby, Mac OS X depends on it.
You can install MacRuby.
It can be installed along with regular Ruby as the commands of MacRuby begins with "mac", so, irb is macirb and ruby is macruby.
Having both installed, you can choose which one use in each moment by prefixing the "mac" string or not
I'd leave the system Ruby alone. Most people would just use RVM to install 1.9, but Homebrew also has Ruby 1.9.2 available.
I'd recommend using Homebrew to install it (into /usr/local).

How can I input multibyte characters in rails console (or irb)?

guys. I am developing a Chinese application with rails. Now I want to input some Chinese characters in rails console but cannot do that, either in irb.
Any guys who have the experience to solve this problem? I would appreciate your help!
Based on #Jimmy-Huang's answer, these are the steps I followed on Mac Leopard using rvm and ruby 1.9.2:
rvm package install readline
rvm remove 1.9.2
rvm install 1.9.2 --with-readline-dir=$rvm_path/usr
That resulted in some errors, particularly when trying bundle install:
uninitialized constant Gem::SilentUI
It turned out that's due to an older version of bundler and this gets rid of it:
gem install bundler
I found the solution for me, it need to re-compile the readline. And now I can input non-ASCII characters!
Because I am using rvm, so I found this article to teach you how to re-compile readline under rvm. http://rvm.beginrescueend.com/packages/readline/
And for someone who is not using rvm, maybe you can follow this post and have a try:
http://henrik.nyh.se/2008/03/irb-readline
By the way, ruby-1.9.2 irb already supports non-ASCII inputing.
Check out the pack method on array:
http://ruby-doc.org/core-1.8.7/classes/Array.html#M000287
I think you'd want:
[111 ,222, 333].pack(U*)
Here is an interesting discussion on the subject had with Matz:
http://www.ruby-forum.com/topic/134919

Ruby Irb reacts strangely to control keys

I'm (extremely) new to Ruby, having started today.
I just moved from my system's Ruby 1.8 installation to Ruby 1.9, compiled from source. In doing so, irb has taken a turn for the worse. It reacts in a most unfriendly way to the non-alphanumeric control keys:
UP key prints: ^[[A
DOWN key prints: ^[[B
DELETE key prints: ^[[3~
...and so on. The main result of this for me is that I have no access to previously issued commands. Nor does tab-completion work; though none of this seems to be an issue with Wirble - the same happens when I remove my ~/.irbrc.
I'm using:
Ubuntu 9.10
GNOME Terminal 2.28.1
ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux]
Irb version 0.9.5 (05/04/13)
Any ideas? :(
This could be a readline issue. You could try installing libreadline and libreadline-dev packages and rebuild Ruby after that, see if it helps:
apt-get install libreadline5 libreadline5-dev
If you use OS X Snow Leopard and have the same problem there is a description how to fix it here: http://snippets.dzone.com/posts/show/10511
readline is the correct answer. just wanted to say that for os x, you can install readline via homebrew.

Resources