This project is archived and is in readonly mode.

#2625 ✓duplicate
Roman Chernyatchik

Rails should exec 'irb' from ruby bin directory instead of PATH

Reported by Roman Chernyatchik | May 8th, 2009 @ 01:25 PM | in 2.x


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 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

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>