Can't enter Umlauts in Ruby 1.9.3 IRB
Asked Answered
R

4

12

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?

Rhaetic answered 30/4, 2012 at 15:7 Comment(2)
What is the output of puts __ENCODING__Unyoke
irb(main):001:0> __ENCODING__ => #<Encoding:UTF-8>Rhaetic
R
6

Victor Moroz didn't quite give the definitive answer but his link led me to a solution (thx!):

I forgot to mention:

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
Rhaetic answered 1/5, 2012 at 7:19 Comment(1)
Fwiw, a simpler command is shown at github.com/guard/guard/wiki/…: CONFIGURE_OPTS=--with-readline-dir=brew --prefix readline rbenv install 1.9.3-p327Abbyabbye
R
5

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!

Reube answered 3/8, 2012 at 13:27 Comment(1)
Nice - worked with 1.9.3 p327 and the falcon patch: rvm reinstall ruby-1.9.3-p327-turbo --with-readline-dir=$rvm_path/usrAvail
P
1

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.

Puberulent answered 30/4, 2012 at 15:50 Comment(1)
Sorry forgot to mention, I installed that ruby using ruby-build.Rhaetic
S
0

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

Shelbashelbi answered 23/1, 2017 at 9:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.