This is what happens on a Debian machine
$ ruby -e 'puts "something"'
something
$
This is what I expected.
However, when I run the same on my Mac (OS X 10.7.3), I get
1.9.3-p125-perf $ ruby -e "puts 'something'"
1.9.3-p125-perf $ ruby -e "print 'something'"
1.9.3-p125-perf $ rbenv shell 1.8.7-p358
1.8.7-p358 $ ruby -e "puts 'something'"
1.8.7-p358 $ ruby -e "print 'something'"
nil1.8.7-p358 $ rbenv shell system
system $ ruby -e "puts 'something'"
system $ ruby -e "print 'something'"
nilsystem $
Does anyone know what’s going on here and how I get ruby to output something meaningful again?
My Ruby versions:
1.9.3-p125-perf: ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
1.8.7-p358: ruby 1.8.7 (2012-02-08 patchlevel 358) [i686-darwin11.3.0]
system: ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
Scripts or IRB work fine, piping ruby also works:
1.9.3-p125-perf $ cat | ruby
puts "foo"
^D
foo
It’s just the ruby -e that behaves funky.
This also happens on my girlfirends Mac. She uses RVM.
I found the culprit. I was using an old version of bundler-exec.
bundler-execcreates shell aliases for a predefined list of commands and wraps them in this function:The version I had was missing the quotation marks around the
$@which somehow caused ruby to misbehave.