昨天我在rails应用程序(v2.3)上使用ruby进行开发,并决定将我的iMac更新为OSX Mavericks。现在,每次我尝试在本地运行我的应用程序时,都会出现以下错误。有谁知道造成这种情况的原因是什么?
像这样运行:
script/server -e development
错误:
/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>'
脚本/服务器(文件)
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
安装OSX Mavericks之前一切正常。
我注意到的事情:
仅供参考:我还是铁杆的新手。
已安装的RVM:
curl -L https://get.rvm.io | bash -s stable --rails
安装Ruby 1.8.7:
rvm install ruby-1.8.7-p374
将v1.8.7设为默认版本:
rvm --default use 1.8.7
安装Rails v2.3.11:
gem install rails -v 2.3.11
从系统安装所有宝石
rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system
现在当我运行我的应用程序时,我收到以下错误:(我错过了什么?)
=> 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
答案 0 :(得分:0)
从这个问题中要理解的主要事情是,您不能依赖于ruby版本的操作系统或您在ruby项目中使用的gem。当您创建其他ruby应用程序时,您可能会再次遇到麻烦。
- To manage the gems use Bundler
Bundler maintains a consistent environment for each ruby applications.
- To manage the Ruby versions use rbenv or rvm