Posted by: Bob Ngu on: June 27, 2008
Ok, now that I have decided not to upgrade Ruby to 1.8.6, see Upgrading Ruby for details, I then moved onto upgrading Rails from 1.2.1 to 2.1, this is still on my Windows XP development machine which is treated like the bastard redheaded step child that it is
Note that I have an existing app in Rails 1.2.1, in fact the app is frozen to Rails 1.2.1, and I have no plans of upgrading the app to Rails 2.1. I am upgrading my development environment to create a new app on Rails 2.1.
First off, different articles have slightly different ways of doing the upgrade. According to this article Migrating to Rails 2.0, it suggested the following commands (it’s the one I ended up following):
gem install rails -y
gem update --system
In another Wiki article HowToUpgrade, it recommends the following commands
sudo gem update rails -y
sudo gem update rake -y
sudo gem update activerecord -y
sudo gem update activesupport -y
sudo gem update actionpack -y
sudo gem update actionmailer -y
sudo gem update activeresource -y or possibly sudo gem install activeresource -y
Yet in another different article, Setting Up Rails Development Environment on Windows Vista/XP, it suggests… In future, whenever you want to update Rails to a newer version, simply run the following command:
C:\> gem update rails
Since I am not a Rails internals expert, I am starting to feel like the blind leading the blind here. After doing an eenie, meenie, minie, moe (not quite but close enough) to catch a mongrel by its tail (sorry couldn’t resist
), I went with the first option.
The first command went without a hitch – this one updates Rails itself
gem install rails –y
The second command seemed to work – this ones updates RubyGems from 0.9.4 to 1.2.0
gem update --system
However, when I tried to start my existing app (it uses Mongrel), it threw an error
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’: no such file to load — c:/ruby/lib/ruby/gems/1.8/gems/mongrel_service-0.3.2-x86-mswin32/lib/mongrel_service/init.rb (MissingSourceFile)
If I start the app using webrick, it works fine. Also, I noticed that the old Rails 1.2.1 gems are still there along with the new 2.1 gems – this is in the C:\ruby\lib\ruby\gems\1.8\gems folder. After getting some advice from the Ruby on Rails forum, I decided to do a gem cleanup with the following command
gem cleanup
Running the command gave me this
Cleaning up installed gems...
Attempting to uninstall rails-1.2.1
Successfully uninstalled rails-1.2.1
Attempting to uninstall actionmailer-1.3.1
Successfully uninstalled actionmailer-1.3.1
Attempting to uninstall activerecord-1.15.1
You have requested to uninstall the gem:
activerecord-1.15.1
actionwebservice-1.2.1 depends on [activerecord (= 1.15.1)]
rails-1.2.1 depends on [activerecord (= 1.15.1)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]
This was unexpected so I terminated the cleanup and did some research and found out that Rails 2.0 made a conscious decision to chuck ActionWebService (SOAP) in favor of ActiveResource (REST). Quoting from this article
ActionWebService out, ActiveResource in
It’ll probably come as no surprise that Rails has picked a side in the SOAP vs REST debate. Unless you absolutely have to use SOAP for integration purposes, we strongly discourage you from doing so. As a naturally extension of that, we’ve pulled ActionWebService from the default bundle. It’s only a gem install actionwebservice away, but it sends an important message none the less.
So the warning regarding actionwebservice makes sense since gem cleanup doesn’t know about actionwebservice for Rails 2.x. To get around the problem, I answered “Y” and proceeded. I encountered a similar prompt later and answered “Y” as well.
Attempting to uninstall fxruby-1.2.6-x86-mswin32
You have requested to uninstall the gem:
fxruby-1.2.6-x86-mswin32
fxri-0.3.3 depends on [fxruby (>= 1.2.0, < 1.3)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]
I hope nothing breaks, if you have any details about this, let me know.
Next, onto resolving the mongrel failure problem. After digging around the net, I came across Latest RubyGems and Rails is a deadly combo. As it turns out all I need to do is go into c:\ruby\lib\ruby\gems\1.8\gems and rename mongrel_service-0.3.2-mswin32 to mongrel_service-0.3.2-x86-mswin32 (note the x86 addition). Mongrel runs fine afterward.
All in all, upgrading Rails to 2.1 is a major PITA and not for the faint of heart.
I recommend starting by reading this: http://www.rubyinside.com/june-2008-ruby-security-vulnerabilities-927.html
Then read this: http://www.ruby-lang.org/en/news/2008/06/20/arbitrary-code-execution-vulnerabilities/
Comments here are also informative: http://weblog.rubyonrails.org/2008/6/21/multiple-ruby-security-vulnerabilities
June 27, 2008 at 5:16 pm
I’m glad you found that article useful! Upgrading is a bit risky; one user followed our instructions and “hosed” their whole system!
By the way, Rails 2.1 (actually, Ruby) has some security issues; I wouldn’t recommend upgrading just yet …