Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Add magic encoding comment to generated files

#701

This ticket is a follow up of:

"[Ruby on Rails #371 Installing rails 2.1 breaks the existing 2.0.2 apps] 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'

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

Reported by Mauro Cicio · July 25th, 2008 @ 10:15 AM

State: duplicate
Milestone: 2.x
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. Michael Koziarski
    Michael Koziarski

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

    July 25th, 2008 @ 10:18 AM

  2. Jan De Poorter
    Jan De Poorter

    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

    July 25th, 2008 @ 10:59 AM

  3. Mauro Cicio
    Mauro Cicio

    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 :-)

    July 25th, 2008 @ 11:45 AM

  4. Mauro Cicio
    Mauro Cicio
    • 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 :-)"

    July 25th, 2008 @ 11:47 AM

  5. Jan De Poorter
    Jan De Poorter
    • Title changed from Errata Corrige to RAILS_GEM_VERSION ignored

    Don't change the ticket name ;-)

    July 25th, 2008 @ 11:49 AM

  6. Michael Koziarski
    Michael Koziarski

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

    July 25th, 2008 @ 01:46 PM

  7. Jan De Poorter
  8. Jan De Poorter
    Jan De Poorter

    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.

    July 25th, 2008 @ 02:20 PM

  9. Michael Koziarski
    Michael Koziarski
    • State changed from new to duplicate

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

    July 25th, 2008 @ 02:25 PM

  10. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 9th, 2010 @ 10:05 PM

  11. Aditya Sanghi
    Aditya Sanghi

    Automatic cleanup of spam.

    October 9th, 2010 @ 10:05 PM

  12. Ryan Bigg
    Ryan Bigg

    Automatic cleanup of spam.

    October 21st, 2010 @ 03:38 AM

  13. Jeff Kreeftmeijer
  14. bingbing
  15. links london