ruby 1.9.2 and rails 2.3 bootstrap
When I tried to launch console in rails 2.3.5 project with ruby 1.9.2 I’ve got nasty error:
# ruby1.9.2 script/console
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- script/../config/boot (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from script/console:2:in `<main>'
Lets look at this file:
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
As ruby 1.9.2 changelog states $: no longer includes the current directory, use require_relative
I tried this command but it failed too:
# ruby1.9.2 script/console
script/console:2:in `require_relative': no such file to load -- /root/code/ruby/testproject/script/config/boot (LoadError)
from script/console:2:in `<main>'
So the solution was to expand path manually and then require it in usual way
#!/usr/bin/env ruby
require File.expand_path(File.dirname(__FILE__) + '/../config/boot')
require 'commands/console'
This manipulations need to be applied for all scripts.