繁体   English   中英

在OS X上升级到ruby 1.9.2后,我的rails项目失败

[英]My rails project fails after upgrading to ruby 1.9.2 on OS X

我已经将ruby升级到1.9.2,rubygems 1.5.0并按照本教程安装了最新的rails 3.0.3:

http://hivelogic.com/articles/ruby-rails-mongrel-mysql-osx

但现在我现有的项目已不再适用。 如果我做一个“ruby脚本/关于”,我得到这个:

<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- /Users/sneigaard/work/rails/myproject/config/../vendor/rails/railties/lib/initializer (LoadError)
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from /Users/sneigaard/work/rails/myproject/config/boot.rb:45:in `load_initializer'
    from /Users/sneigaard/work/rails/myproject/config/boot.rb:38:in `run'
    from /Users/sneigaard/work/rails/myproject/config/boot.rb:11:in `boot!'
    from /Users/sneigaard/work/rails/myproject/config/boot.rb:110:in `<top (required)>'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from <internal:lib/rubygems/custom_require>:29:in `require'
    from script/about:2:in `<main>'

如果我运行“mongrel_rails start”,我会收到此错误:

** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `gem_original_require': no such file to load -- /Users/sneigaard/work/rails/myproject/config/../vendor/rails/railties/lib/initializer (LoadError)
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `require'
    from /Users/sneigaard/work/rails/myproject/config/boot.rb:45:in `load_initializer'
    from /Users/sneigaard/work/rails/myproject/config/boot.rb:38:in `run'
    from /Users/sneigaard/work/rails/myproject/config/boot.rb:11:in `boot!'
    from /Users/sneigaard/work/rails/myproject/config/boot.rb:110
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `require'
    from /Users/sneigaard/work/rails/myproject/config/environment.rb:7
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `require'
    from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:147:in `rails'
    from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:113:in `cloaker_'
    from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `call'
    from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:149:in `listener'
    from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:99:in `cloaker_'
    from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `call'
    from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:50:in `initialize'
    from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `new'
    from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:84:in `run'
    from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
    from /Library/Ruby/Gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    from /usr/bin/mongrel_rails:19:in `load'
    from /usr/bin/mongrel_rails:19

在脚本/服务器中我有这个:

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

我搜索并搜索了网,但我无法弄明白,我的项目被卡住了:(请帮助我。

谢谢
索伦

rails server发出了同样的错误吗? 你似乎在rails 3中使用rails 2命令。还有,你的所有宝石都加载到1.9.2吗? 切换红宝石时必须重新加载所有内容。

如果你打字,你的红宝石会有一些误配置

which ruby
gem environment

ruby -v

它是全能的吗?

我建议使用RVM非常简单,以便为您的商务设置良好的文档和有用。

似乎你的项目仍然在rails 2.3。*而不是3.0。*,在rails 3中,thear不是脚本/服务器脚本文件。 安装rvm ruby​​ 1.9.2和正确的gem到你的项目。

希望这可以帮助。

将应用程序从1.8.7升级到1.9.2时遇到此问题。
在Ruby 1.9.2中,Kernel.require不像1.8那样工作,而是看起来他们希望你使用Kernel.require_relative

请参阅此处以了解适用于两种红宝石的解决方案

Ruby:require vs require_relative - 在Ruby <1.9.2和> = 1.9.2中运行的解决方法的最佳实践

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM