41

I upgraded my ruby to 1.9.2 and now when I try to start up a Rails 2.3.5 app with script/server I get this error:

<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/server:2:in `<main>'

But script/server:2 definitely looks correct, and the file config/boot.rb exists in the right place.

dan
  • 43,914
  • 47
  • 153
  • 254

7 Answers7

83

Much simpler, does not require modification of all scripts:

Instead of:

script/server 

call:

./script/server
UncleGene
  • 2,132
  • 16
  • 19
  • This was awesome. Helped me with Gitorious. – rahul Jun 15 '11 at 20:32
  • 1
    File.dirname(__FILE__) + '/../confg/boot' (used in server) takes dirname from the invoking command. When you call 'script/server', it tries to find 'script/../config/boot' using LOAD_PATH (unsuccessfully). When you call './script/server', it translates to './script/../config/boot' - with current dir explicit in the path. – UncleGene Nov 30 '11 at 05:42
  • tried this too, but it's not working: script/server /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- test/unit/error (LoadError) from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' – Thomas Mar 05 '12 at 22:01
53

Replacing line 2 of script/server with

require File.expand_path('../../config/boot', __FILE__)

works for me (taken from Rails 3)

Ian Fleeton
  • 1,157
  • 8
  • 14
  • Tried this but still get script/server /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- test/unit/error (LoadError) from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' What am I missing? – Thomas Mar 05 '12 at 21:59
13

it's because ruby 1.9.2 doesn't add the current directory in the LOAD_PATH.

Add this that in top of your script/server file:

$: << File.dirname(__FILE__)

Or in your case:

$: << File.dirname(__FILE__) + '..'
Tom
  • 15,527
  • 5
  • 48
  • 62
shingara
  • 46,608
  • 11
  • 99
  • 105
  • not working: ./server /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- . (LoadError) from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from ./server:3:in `
    ' What am I missing?
    – Thomas Mar 05 '12 at 22:06
1

I met the exact same problem as described. Ubuntu 10.04 x64, Eclipse Helio, AptanaStudion2 with RadRail, Ruby 1.9.2, Rails 2.3.5 this doesn't work for me:

require File.expand_path('../../config/boot', __FILE__)

This works for me

require File.expand_path(__FILE__)+ '/../../config/boot'
Jing
  • 111
  • 1
  • 3
0

You might try to add the path source /usr/share/ruby-rvm/scripts/rvm

0

Please check your root path before start padrino. like if your application in "C:\XXXXXXX\YYYYYYY\ZZZ-padrino" here and you are in "C:\XXXXXXX\YYYYYYY\" in command prompt then this error will occur. then you should in "C:\XXXXXXX\YYYYYYY\ZZZ-padrino".

Skyfall
  • 57
  • 8
0

The $: << File.dirname(__File__) + '..' won't work since you'd get a dir of

'script..'

Try

$: << File.join(File.dirname(__FILE__),'..')
  • not working: ./server /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- ./.. (LoadError) from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from ./server:3:in `
    ' What am I missing?
    – Thomas Mar 05 '12 at 22:07