Rbenv: Cannot load such file "script/../config/boot'

Created on 17 Sep 2015  ·  4Comments  ·  Source: rbenv/rbenv

I just moved from rvm`` torbenv```. 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?

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:

./script/console

instead of just calling:

/script/console

Works like a champ.

All 4 comments

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:

  1. edit $LOAD_PATH to include the current directory (by e.g. $LOAD_PATH << ".");
  2. use require_relative "../config/boot" in script/console; or
  3. just ditch script/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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bradrydzewski picture bradrydzewski  ·  4Comments

MichalMichalak picture MichalMichalak  ·  3Comments

aaalveee picture aaalveee  ·  4Comments

sonnybrakes picture sonnybrakes  ·  4Comments

sandys picture sandys  ·  4Comments