更改所使用的 Rails 版本

发布于 2025-01-02 05:54:25 字数 2421 浏览 0 评论 0原文

我有一个 RoR 应用程序在 Fedora14 下运行得很好,我升级到了 Fedora16,现在它变得一团糟。

这是由于使用的 Rails 发生了变化,Fedora 14 运行在 2.x 上,现在 Fedora 15/16 运行在 3.x 上

我安装了 rvm,之前我没有安装 Rails gem,所以它会回退到系统(?)。所以我已经安装了 Rails 2.3.8 的 gem,当我做 gem 列表时它会显示出来,但是该应用程序仍然是一团糟。

有人有任何线索吗,我应该检查、做什么、粉碎什么?

所以我将其添加到我的 config/enviroment.rb 中

  config.gem "rails", :version => "~> 2.3.8"

,当我开始时,我现​​在收到此错误(这全部在一行上)。

Error message:
    NOTE: Gem.source_index is deprecated, use Specification. 
    It will be removed on or after 2011-11-01. Gem.source_index called from /var/work_sites/mysite/vendor/rails/railties/lib/rails/gem_dependency.rb:106. 

    NOTE: Gem::SourceIndex#search is deprecated with no replacement. 
    It will be removed on or after 2011-11-01. Gem::SourceIndex#search called from /var/work_sites/mysite/vendor/rails/railties/lib/rails/gem_dependency.rb:106.
    Missing these required gems: rails ~> 2.3.8 You're running: ruby 1.8.7.357 at /usr/bin/ruby rubygems 1.8.11 at /usr/lib/ruby/gems/1.8, /home/nick/.gem/ruby/1.8 Run `rake gems:install` to install the missing gems. 

然而 $ gem list

*** LOCAL GEMS ***

...
rails (2.3.8)
....

所以我还是尝试一下;

$ rake gems:install
rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)
Missing these required gems:
  rails  ~> 2.3.8

You're running:
  ruby 1.8.7.352 at /home/nick/.rvm/rubies/ruby-1.8.7-p352/bin/ruby
  rubygems 1.8.10 at /home/nick/.rvm/gems/ruby-1.8.7-p352, /home/nick/.rvm/gems/ruby-1.8.7-p352@global

Run `rake gems:install` to install the missing gems.

啊啊!

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.10
  - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/nick/.rvm/gems/ruby-1.8.7-p352
  - RUBY EXECUTABLE: /home/nick/.rvm/rubies/ruby-1.8.7-p352/bin/ruby
  - EXECUTABLE DIRECTORY: /home/nick/.rvm/gems/ruby-1.8.7-p352/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/nick/.rvm/gems/ruby-1.8.7-p352
     - /home/nick/.rvm/gems/ruby-1.8.7-p352@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

I had a RoR app working fun under Fedora14, I upgraded to Fedora16 and now it's a broken mess.

This is due to a change in the rails used, with Fedora 14 running on 2.x and now Fedora 15/16 running 3.x

I have rvm installed, previously I didn't have the rails gem installed, so it would fall back to the system(?). So I've installed the gem for rails 2.3.8, it shows up when I do a gem list however the app is still a broken mess.

Anyone have any sort of clue here, what I should check, do, smash?

So I added this, to my config/enviroment.rb

  config.gem "rails", :version => "~> 2.3.8"

and when I start I now get this error (this was all on one line).

Error message:
    NOTE: Gem.source_index is deprecated, use Specification. 
    It will be removed on or after 2011-11-01. Gem.source_index called from /var/work_sites/mysite/vendor/rails/railties/lib/rails/gem_dependency.rb:106. 

    NOTE: Gem::SourceIndex#search is deprecated with no replacement. 
    It will be removed on or after 2011-11-01. Gem::SourceIndex#search called from /var/work_sites/mysite/vendor/rails/railties/lib/rails/gem_dependency.rb:106.
    Missing these required gems: rails ~> 2.3.8 You're running: ruby 1.8.7.357 at /usr/bin/ruby rubygems 1.8.11 at /usr/lib/ruby/gems/1.8, /home/nick/.gem/ruby/1.8 Run `rake gems:install` to install the missing gems. 

however
$ gem list

*** LOCAL GEMS ***

...
rails (2.3.8)
....

so I try anyway;

$ rake gems:install
rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)
Missing these required gems:
  rails  ~> 2.3.8

You're running:
  ruby 1.8.7.352 at /home/nick/.rvm/rubies/ruby-1.8.7-p352/bin/ruby
  rubygems 1.8.10 at /home/nick/.rvm/gems/ruby-1.8.7-p352, /home/nick/.rvm/gems/ruby-1.8.7-p352@global

Run `rake gems:install` to install the missing gems.

ARGHH!

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.10
  - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/nick/.rvm/gems/ruby-1.8.7-p352
  - RUBY EXECUTABLE: /home/nick/.rvm/rubies/ruby-1.8.7-p352/bin/ruby
  - EXECUTABLE DIRECTORY: /home/nick/.rvm/gems/ruby-1.8.7-p352/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/nick/.rvm/gems/ruby-1.8.7-p352
     - /home/nick/.rvm/gems/ruby-1.8.7-p352@global
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

硬不硬你别怂 2025-01-09 05:54:25

如果应用程序“大小合理”(里程可能会有所不同),请利用此机会升级到 Rails 3。Rails 4 将于今年春天发布,您会发现没有比现在更好的升级时间了。我最初会使用 v3.0.11,如果进展顺利的话会转到 3.1.x。
面对现实吧,你不想很快再次这样做。此时,您还会发现,您遇到的任何问题通常都会被其他人解决和解决,并且可以通过 SO 等在网上找到。

这些将有所帮助:

http://railscasts.com/episodes/225-upgrading-to-rails-3-part-1

http://ryanbigg.com/2010/11/the-rails-3-升级/

http://www.railsupgradehandbook.com/ (12 美元)

Ruby 和 Rails 的变化非常迅速,保持最新状态非常重要,而不仅仅是“有就更好”。此时,gems 更符合 Rails 3

当您使用它时,您应该安装 ruby​​ 1.9.3 除非代码具有复杂的 ruby​​,否则您很可能不会遇到什么问题。 Ruby 2.0 很快就会发布。

正如其他人所建议的那样,rvm 是管理 ruby​​ 版本的关键。安装后,您可以使用像 rvm use 1.9.2 这样简单的命令切换 ruby​​ 版本,并且可以在项目的根目录中创建一个 .rvrmc 文件来设置该项目的 ruby​​ 版本。

除了安装 gem 之外,您需要做的事情之一就是将其放入您的环境文件 - Rails 2 或 Gemfile 和 Bundle - Rails 3 中

If the application is "reasonable sized" (mileage may vary), use this opportunity to upgrade to rails 3. Rails 4 will be out this spring and you will find no better time than now to do the upgrade. I would do v3.0.11 initially and go to 3.1.x if it goes well.
Face it, you don't want to do this again soon. At this point you will also find that whatever problems you encounter have usually be met and fixed by others and findable on the net, thru SO, etc.

These will help:

http://railscasts.com/episodes/225-upgrading-to-rails-3-part-1

http://ryanbigg.com/2010/11/the-rails-3-upgrade/

http://www.railsupgradehandbook.com/ ($12)

Ruby and Rails are changing very rapidly and keeping somewhat current is really important, not justa 'nice-to-have'. At this point gems's are more in line with rails 3

While you are at it you should install ruby 1.9.3 It's quite likely you will have few issues with that unless the code has complex ruby. Ruby 2.0 will be out soon after all.

As others advise rvm is the key to managing ruby versions. Once you have it installed you can switch ruby versions with command as simple as rvm use 1.9.2 and you can create a .rvrmc file in the root of project to set the ruby version for that project.

Once of the things you need to do other than install a gem is put itin your environment file(s) - rails 2 or in your Gemfile and Bundle - rails 3

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文