简体   繁体   中英

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.

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/

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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