This project is archived and is in readonly mode.
TemplateRunner adds gems to environment file in reverse of written order
Reported by CS Merritt (csmosx) | June 30th, 2009 @ 09:52 PM | in 2.x
Each successive gem command in an app template places the corresponding config.gem line above the previous one.
This makes the environment file's config.gem lines the reverse order of the app templates gem commands, potentially causing requirement failures.
Example app template gem commands:
gem 'authlogic'
gem 'authlogic-oid', :lib => "authlogic_openid"
gem 'somegem'
Creates these environment.rb lines:
config.gem 'somegem'
config.gem 'authlogic-oid', :lib => 'authlogic_openid'
config.gem 'authlogic'
Running the rake gems task then would abort at that
authlogic-oid line with:
rake aborted! undefined method
add_acts_as_authentic_module' for ActiveRecord::Base:Class</code> </pre>
I can't think of an easy fix other than some sort of counter to keep track of how many lines have been added after the sentinel.
For now I'll just have to construct my templates in reverse order as needed.
Comments and changes to this ticket
-
Yehuda Katz (wycats) July 1st, 2009 @ 07:49 PM
- State changed from new to verified
Templates are going to be reworked in Rails 3 by José Valim (as part of his GSoC project). Pratik, do you think we should fix this on the 2.3 branch?
-
Yehuda Katz (wycats) July 1st, 2009 @ 08:43 PM
- State changed from open to hold
We looked into this a bit. The problem is that Rails inserts all new text at the top of the environment, using a regex sentinel that looks for the initializer start. The solution is non-trivial, but a patch would be welcome :)
-
CS Merritt (csmosx) July 3rd, 2009 @ 06:25 AM
Here's a patch... or two.
template_gem_order_fix just fixes the gem ordering problem.
template_env_order_fix applies both the gem fix and the same fix to route, which had the same ordering problem and used the same function (gsub_file) which I replaced (with regex_file_splice).
Thanks =)
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>