Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#2625

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

Reported by Roman Chernyatchik · May 8th, 2009 @ 01:25 PM

State: duplicate
Milestone: 2.x
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. CancelProfileIsBroken
    CancelProfileIsBroken
    • Assigned user set to Jeremy Kemper

    Related ticket: #2104 script/console execs irb, causes double process-launch and limits other impls - which proved to have unwanted side effects.

    May 8th, 2009 @ 03:11 PM

  2. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to duplicate

    September 13th, 2009 @ 01:27 PM