I emerged rubygems and ran 'ruby-config ruby18_with_gems'. Now /usr/bin/ruby is a symlink to /usr/bin/ruby18_with_gems. This file contains only one line: RUBYOPT="-rubygems" /usr/bin/ruby18 "$@" It has not even "#!/bin/bash" at the beginning. This works as long as you start ruby out of a shell as in 'ruby my_script.rb', because bash will treat /usr/bin/ruby as a shell script. But if you start it e. g. out of strace (as in strace ruby -e 'puts "hello"'), you will get something like execve("/usr/bin/ruby", ["ruby", "-e", "puts \"hello\""], [/* 63 vars */]) = -1 ENOEXEC (Exec format error) Worse, you cannot use ruby in a she-bang: pepe@cyan /tmp $ cat > test.rb #!/usr/bin/ruby puts 'hello' pepe@cyan /tmp $ chmod 755 test.rb pepe@cyan /tmp $ ./test.rb ./test.rb: line 2: puts: command not found To be used in a she-bang, /usr/bin/ruby has to be a binary program.
I suggest that RUBYOPT=-rubygems be set in /etc/env.d
We tried it as an environment variable and it fails miserably, unfortunately. This was the best solution. I'll put a shebang in the ruby_with_gems script, but I think the easiest solution is to simply use #!/usr/bin/ruby18 in your ruby scripts.
Okay, I've just committed a new rubygems that gets away from using ruby18_with_gems. Please go back to ruby18 with ruby-config, and after an uprade I think all will be well again.