#701 √ duplicate
Mauro Cicio

RAILS_GEM_VERSION ignored

Reported by Mauro Cicio | July 25th, 2008 @ 10:15 AM | in 2.x

This ticket is a follow up of:

"[Ruby on Rails #371] Installing rails 2.1 breaks the existing 2.0.2 apps"

Problem: it seems that if the gem Rails 2.1.0 is installed, then the directive RAILS_GEM_VERSION is ignored.

Following you find the relevant parts of my environment. If more is needed, please ask for it.

  • OS: Debian etch stable
  • Ruby: 1.8.6 compiled from sources (not a debian package)
  • Application created with Rails 2.0.2

Environment (old):

  • Rails 2.0.2
  • Mongrel 1.1.4

$ ./script/server

Works fine

Environment (new):

  • Rails 2.1.0
  • Mongrel 1.1.5 (or 1.1.4)

$ ./script/server

Gives:

=> Booting Mongrel (use 'script/server webrick' to force WEBrick)

=> Rails 2.1.0 application starting on http://0.0.0.0:3000

=> Call with -d to detach

=> Ctrl-C to shutdown server

** Starting Mongrel listening at 0.0.0.0:3000

** Starting Rails with development environment...

Your config/boot.rb is outdated: Run "rake rails:update".

=======================================

$ cat ./config/environment.rb

RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION

require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|

config.frameworks -= [ :action_web_service ]

config.action_controller.session_store = :p_store

config.active_record.observers = :notification_observer, :alert_observer

end

MM = 'system/mm'

$product ||= 'internal'

$host_for_mail ||= $product + '.qnoodle.com'

--------------------------------------------------

Comments and changes to this ticket

  • Michael Koziarski

    Michael Koziarski July 25th, 2008 @ 10:18 AM

    Thanks for that, out of interest, what happens if you remove the unless defined? condition?

  • Jan De Poorter

    Jan De Poorter July 25th, 2008 @ 10:59 AM

    Rails ignores the RAILS_GEM_VERSION because of a bad regular expression. It is the first line of your code, and rails requires a character to exist before RAILS_GEM_VERSION.

    It has to do with these lines in config/boot.rb:

    @@

    environment_without_comments = IO.readlines(File.dirname(__FILE__) + '/environment.rb').reject { |l| l =~ /^#/ }.join

    environment_without_comments =~ /[^#]RAILS_GEM_VERSION = '([\d.]+)'/

    @@

    It works if you change the regex to

    @@

    /[^#]?RAILS_GEM_VERSION = '([\d.]+)'/

    @@

    This is fixed with the 2.1 config file where the regexp is:

    @@

    /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/

    @@

    I suggest backporting this to 2.0.3, as a workaround you can just add a blank line (no comment!) before the RAILS_GEM_VERSION

  • Mauro Cicio

    Mauro Cicio July 25th, 2008 @ 11:45 AM

    Fixed!

    Michael,

    Removing the "unless defined?" doesn't change anything.

    Jan,

    My config/environment.rb now starts with the following 3 lines:

    # The next line must be blank! Necessary to avoid issues with 2.1.0.
    
    RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION
    

    and now the RAILS_GEM_VERSION is picked up as you expected.

    The case of people having the RAILS_GEM_VERSION is not that common I guess: thanks a lot for spending time on this dusty corner :-)

  • Mauro Cicio

    Mauro Cicio July 25th, 2008 @ 11:47 AM

    • → Title changed from “RAILS_GEM_VERSION ignored” to “Errata Corrige ”

    Of course I meant to say:

    "The case of people having the RAILS_GEM_VERSION in the first line is not that common I guess: thanks a lot for spending time on this dusty corner :-)"

  • Jan De Poorter

    Jan De Poorter July 25th, 2008 @ 11:49 AM

    • → Title changed from “Errata Corrige ” to “RAILS_GEM_VERSION ignored”

    Don't change the ticket name ;-)

  • Michael Koziarski

    Michael Koziarski July 25th, 2008 @ 01:46 PM

    It should be possible to change that regular expression to avoid this problem entirely. Care to take a crack at it?

  • Jan De Poorter
  • Jan De Poorter

    Jan De Poorter July 25th, 2008 @ 02:20 PM

    Ok, after looking into this a bit more, 2-0-stable and 2.0.2 already fixed this bug.

    All you have to do is update your config file so it respects your RAILS_GEM_VERSION and then run rake rails:update. This will update your boot.rb file to the 2.0.2 one, which is the good one.

  • Michael Koziarski

    Michael Koziarski July 25th, 2008 @ 02:25 PM

    • → State changed from “new” to “duplicate”

    Resolving as a duplicate because it's been fixed already.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Source available from github

The Git repository resides at http://github.com/rails

Check out the current development trunk (Edge Rails) with:

git clone git://github.com/rails/rails.git

Creating or reviewing a patch

See the contributor guide.

Creating a feature request

Please don't. If you want a new feature in Rails, you'll have to pull up your sleeves and get busy yourself. Or convince someone else to do it. See the contributor guide on how to get going. But posting them here is just going to lead to ticket root.

Creating a bug report

When creating a bug report, be sure to include as much relevant information as possible. Post the code sample that causes the problem. Preferably, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.

Security vulnerabilities should be reported via an email to security@rubyonrails.org, do not use trac for reporting security vulnerabilities. All content in trac is publicly available as soon as it is posted.

Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kinda bug, you're creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to sign on to with a "I'm having this problem too".

Shared Ticket Bins

Tags