This project is archived and is in readonly mode.

#701 ✓duplicate
Mauro Cicio

Add magic encoding comment to generated files

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.

  • Ryan Bigg

    Ryan Bigg October 9th, 2010 @ 10:05 PM

    • Tag cleared.

    Automatic cleanup of spam.

  • Aditya Sanghi

    Aditya Sanghi October 9th, 2010 @ 10:05 PM

    Automatic cleanup of spam.

  • Ryan Bigg

    Ryan Bigg October 21st, 2010 @ 03:38 AM

    Automatic cleanup of spam.

  • Jeff Kreeftmeijer
  • bingbing
  • links london

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages