5

我昨天在 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 之前它运行良好。

我注意到的事情:

  • 现在安装的 ruby​​ 版本是 2.0(之前是 v1.8.7)

仅供参考:我对 Rails 还是很陌生。

安装 RVM 后:


好的,所以我设置了 RVM 并确保 ruby​​ (1.8.7) 和 rails (2.3.11) 的版本已安装并配置为默认值。

安装的 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

从系统安装所有 gem

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
4

1 回答 1

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 
于 2013-12-25T21:35:57.140 回答