I just moved from rvm`` to
rbenv```. I needed to install a newer version of ruby and I wanted to insulate the ruby that was running for a legacy Rails 2.3.15 application I have on this server.
I have had that legacy app working with Bundler for 2 years.
After reinstalling ruby, my Rails application refuses to load. I ended up installing a newer version of Ruby (2.1.5) since it was a nightmare trying to get any version of 1.8.7 (openssl issues) or 1.9.3 installed via rbenv. I don't think this is a shortcoming of rbenv, just configuration changes over the years.
Anyway, this 2.1.5 ruby version absolutely refuses to load the config/boot.rb
file. Just flat out says it can't load it. Very unhelpful.
The require
line that is failing in script/console
:
require File.dirname(__FILE__) + '/../config/boot'
/home/myapp/.rbenv/versions/2.1.5/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- script/../config/boot (LoadError)
At the top of this script/console
file is:
#!/usr/bin/env ruby
Could that somehow be causing a problem?
In newer versions of Ruby, the current directory is no longer in $LOAD_PATH
by default. That means that using require
to load files relative to the current directory (such as script/../config/boot
which expands to simply config/boot
) won't work.
Your alternatives are:
$LOAD_PATH
to include the current directory (by e.g. $LOAD_PATH << "."
);require_relative "../config/boot"
in script/console
; orscript/console
and use rails console
which is the new way of starting the console in newer Rails versions.It's not rbenv problem. Rails 2.3 (already EOL) do not support Ruby 1.9 later.
@hsbt Ah yes, thanks for reminding me: rails console
is only a thing since Rails 3.
@HuckyDucky It shouldn't be impossible to install an older version of Ruby on your computer.
It's probably not impossible, but it's excruciatingly painful on RedHat. Lots of known issues with compiling against RH's OpenSSL with Ruby 1.8.7. I just have to last a little longer with this old app during the rewrite.
It's silly, but I was able to run this using:
./script/console
instead of just calling:
/script/console
Works like a champ.
Most helpful comment
It's probably not impossible, but it's excruciatingly painful on RedHat. Lots of known issues with compiling against RH's OpenSSL with Ruby 1.8.7. I just have to last a little longer with this old app during the rewrite.
It's silly, but I was able to run this using:
instead of just calling:
Works like a champ.