Permalink
Browse files

Correct RAILS_GEM_VERSION regexp. Use =version gem requirement instea…

…d of ~>version so you don't get surprised by a beta gem in production. This change means upgrading to 1.2.5 will require a boot.rb upgrade.

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-stable@7832 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
jeremy committed Oct 11, 2007
1 parent a692432 commit e08527014a1bf3db11a86771736976bbae514059
Showing with 13 additions and 8 deletions.
  1. +2 −0 railties/CHANGELOG
  2. +11 −8 railties/environments/boot.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Correct RAILS_GEM_VERSION regexp. Use =version gem requirement instead of ~>version so you don't get surprised by a beta gem in production. This change means upgrading to 1.2.5 will require a boot.rb upgrade. [Jeremy Kemper]
+
* Move custom inflections example so available before route generation. #6829 [dcmanges, Nate, piotrb]
@@ -8,20 +8,23 @@
else
require 'rubygems'
- environment_without_comments = IO.readlines(File.dirname(__FILE__) + '/environment.rb').reject { |l| l =~ /^#/ }.join
- environment_without_comments =~ /[^#]RAILS_GEM_VERSION = '([\d.]+)'/
- rails_gem_version = $1
+ rails_gem_version =
+ if defined? RAILS_GEM_VERSION
+ RAILS_GEM_VERSION
+ else
+ File.read("#{File.dirname(__FILE__)}/environment.rb") =~ /^[^#]*RAILS_GEM_VERSION\s+=\s+'([\d.]+)'/
+ $1
+ end
- if version = defined?(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : rails_gem_version
- # Asking for 1.1.6 will give you 1.1.6.5206, if available -- makes it easier to use beta gems
- rails_gem = Gem.cache.search('rails', "~>#{version}.0").sort_by { |g| g.version.version }.last
+ if rails_gem_version
+ rails_gem = Gem.cache.search('rails', "=#{rails_gem_version}.0").sort_by { |g| g.version.version }.last
if rails_gem
gem "rails", "=#{rails_gem.version.version}"
require rails_gem.full_gem_path + '/lib/initializer'
else
- STDERR.puts %(Cannot find gem for Rails ~>#{version}.0:
- Install the missing gem with 'gem install -v=#{version} rails', or
+ STDERR.puts %(Cannot find gem for Rails =#{rails_gem_version}.0:
+ Install the missing gem with 'gem install -v=#{rails_gem_version} rails', or
change environment.rb to define RAILS_GEM_VERSION with your desired version.
)
exit 1

0 comments on commit e085270

Please sign in to comment.