简体   繁体   English

更改使用的滑轨的版本

[英]Change the version of rails used

I had a RoR app working fun under Fedora14, I upgraded to Fedora16 and now it's a broken mess. 我在Fedora14下获得了RoR应用程序的工作乐趣,我升级到Fedora16,现在真是一团糟。

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 这是由于使用的滑轨发生了变化,Fedora 14在2.x上运行,而Fedora 15/16在3.x上运行。

I have rvm installed, previously I didn't have the rails gem installed, so it would fall back to the system(?). 我已经安装了rvm,以前我没有安装rails gem,所以它会退回到系统(?)。 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. 因此,我已经安装了Rails 2.3.8的gem,当我执行gem列表时会显示它,但是该应用程序仍然很混乱。

Anyone have any sort of clue here, what I should check, do, smash? 有人在这里有什么线索,我应该检查,解决,粉碎吗?

So I added this, to my config/enviroment.rb 所以我将其添加到了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/

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. 如果应用程序的大小“合理”(里程可能会有所不同),请利用此机会升级到Rails3。Rails4将于今年春天发布,您会发现现在没有比现在更好的时间了。 I would do v3.0.11 initially and go to 3.1.x if it goes well. 我最初会做v3.0.11,如果一切顺利,请转到3.1.x。 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. 在这一点上,您还将发现通常遇到的任何问题都可以由其他人解决,并且可以通过SO等在网上找到。

These will help: 这些将有助于:

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

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

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

Ruby and Rails are changing very rapidly and keeping somewhat current is really important, not justa 'nice-to-have'. Ruby和Rails的变化非常快,保持最新状态确实很重要,而不仅仅是“必备”。 At this point gems's are more in line with rails 3 在这一点上,宝石更符合轨道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 1.9.3。除非代码中包含复杂的ruby,否则很有可能会出现一些问题。 Ruby 2.0 will be out soon after all. 毕竟,Ruby 2.0将很快问世。

As others advise rvm is the key to managing ruby versions. 正如其他人建议的那样,rvm是管理ruby版本的关键。 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. 安装完成后,您可以rvm use 1.9.2这样的简单命令来切换ruby版本,并且可以在项目的根目录中创建.rvrmc文件来为该项目设置ruby版本。

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 除了安装gem以外,您还需要做的其他事情都会放入环境文件-rails 2或Gemfile and Bundle-rails 3中。

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

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