cannot load such file — script/../config/boot (LoadError) after OSX Mavericks

一曲冷凌霜 提交于 2019-12-10 14:53:40

问题


I was doing development on a ruby on a rails application (v2.3) yesterday and decided to update my iMac to OSX Mavericks. Now, every time I try to run my application locally, I get the following error. Does anyone know whats causing this?

Run like this:

script/server -e development

Error:

 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- script/../config/boot (LoadError)
        from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
        from script/server:2:in `<main>'

script/server (file)

#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'

It was working fine before installing OSX Mavericks.

Things I Noticed:

  • the version of ruby installed in now 2.0 (it was v1.8.7 before)

FYI: I'm still fairly new to rails.

After Installing RVM:


Ok so I setup RVM and made sure the version of ruby (1.8.7) and rails (2.3.11) are installed and configured as the default.

Installed RVM:

curl -L https://get.rvm.io | bash -s stable --rails

Install Ruby 1.8.7:

rvm install ruby-1.8.7-p374

Set v1.8.7 as the default version:

rvm --default use 1.8.7

Install Rails v2.3.11:

gem install rails -v 2.3.11

Install all the gems from system

rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system

Now when I run my app, I get the following error: (what am I missing?)

=> Booting WEBrick...
/Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `gem_original_require': no such file to load -- haml (MissingSourceFile)
    from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:355:in `new_constants_in'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/plugins/haml/init.rb:5:in `evaluate_init_rb'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:95:in `evaluate_init_rb'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:91:in `evaluate_init_rb'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:44:in `load'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:33:in `load_plugins'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:32:in `each'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:32:in `load_plugins'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:292:in `load_plugins'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:142:in `process'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:97:in `send'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:97:in `run'
    from /Users/imaginationplus/gitlocal/dfc_workshop/config/environment.rb:14
    from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `gem_original_require'
    from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:355:in `new_constants_in'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/railties/lib/commands/servers/webrick.rb:59
    from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `gem_original_require'
    from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:355:in `new_constants_in'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/railties/lib/commands/server.rb:39
    from script/server:3:in `require'
    from script/server:3

回答1:


The main thing to understand from this issue is that you cannot rely on the OS for your ruby version or the gems that you are using within a ruby project. As you create additional ruby apps you may run into trouble with this again.

-  To manage the gems use Bundler
   Bundler maintains a consistent environment for each ruby applications. 

-  To manage the Ruby versions use rbenv or rvm 


来源:https://stackoverflow.com/questions/19566717/cannot-load-such-file-script-config-boot-loaderror-after-osx-mavericks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!