Thursday, February 2, 2012

Ruby on Rails 3.2 had been released. (with one stumbling point)

About two weeks ago, Ruby on Rails 3.2 had been released. To update to the rails 3.2.0 or higher, you not only do the "gem update" or "bundle update" but also copy rails command file and rackup command file manually. There is only one stumbling point when updating to the rails 3.2.0 or higher - despite ruby-gems related with rails are upgraded successfully, rails command and rackup command are NOT.

Let's check your rails command on your Ruby path. If rails command is like below, that is still older one. For example, check /usr/bin/rails:
#!/usr/bin/ruby1.9
#
# This file was generated by RubyGems.
#
# The application 'rails' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end

gem 'rails', version
load Gem.bin_path('rails', 'rails', version)

You should copy latest command file from bin path on your gem directory to ruby path. For example, check the latest command file on /usr/lib/ruby/gems/1.9.1/bin/rails:
#!/usr/bin/env ruby1.9
#
# This file was generated by RubyGems.
#
# The application 'railties' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
version = $1
ARGV.shift
end

gem 'railties', version
load Gem.bin_path('railties', 'rails', version)

As you check these files, real substance of rails command moves from rails gem to railties gem, so that you should do below manually:
> sudo cp /usr/lib/ruby/gems/1.9.1/bin/rails /usr/bin/rails

And then, you could do same operations about /usr/lib/ruby/gems/1.9.1/bin/rackup.

No comments:

Post a Comment