Hello,
I have got two ruby interpreters installed on my computer. E.g:
/usr/bin/ruby and /opt/local/bin/ruby. The first one(/usr/bin/ruby)
in is PATH env variable. I've generated rails application using the
2nd interpreter and if I try to execute
./script/console with: /opt/local/bin/ruby
./script/console - rails will load it using /usr/bin/irb
instead of /opt/local/bin/irb. Thus rails will load
console with Gem.path of 1st interpreter. Also if 1st interpreter
has got out of date rubygems it will warn about rubygems of
/usr/bin/ruby interpreter.
I've found the problem. Please look at file
rails-2.3.2/lib/commands/console.rb :
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
...
opt.on("--irb=[#{irb}]", 'Invoke a different irb.') { |v| options[:irb] = v }
...
exec "#{options[:irb]} #{libs} --simple-prompt"
Thus it can be fixed by replacing first string with:
irb = File.join(Config::CONFIG['bindir'],
RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb')
Unfortunately I wasn't managed to write good test for this patch
thus I didn't submit patch using rails contributor guide.
P.S: This bug affects Users of IDEs under MacOS. Because due to
some Mac specific environment variables extended in ~/.profile
aren't populated to all MacOS applications except Terminal.app.
Obviously we can load rails console with --irb
option but it looks as ugly hack. Also rake and
spec gems use the similar
solution(Config::CONFIG['bindir']) to find current ruby interpreter
executable file instead of executing 'ruby' command from PATH