Add rails/init.rb to gemspec

Skip to first unread message

Paul Barry

Aug 26, 2008, 4:34:05 PM8/26/08
to Haml
Here's a little patch that adds rails/init.rb to the gemspec, so that
when you "rake install" haml, it puts that file in the gem, so that
Rails 2.1 apps don't have to generate the plugin with "haml --rails",
you just have to put config.gem "haml", :version => '>= 2.1.0' in

Nathan Weizenbaum

Aug 26, 2008, 4:42:54 PM8/26/08
Heh, oops. Pushed.

Wincent Colaiuta

Sep 6, 2008, 5:53:18 PM9/6/08
to Haml
Interesting. Does this actually work for you? I can't get this to work
with Haml 2.0.2 and Rails 2.1.1.

There does seem to be at least a couple of bugs in Rails' support of
frozen gems:

I found that Haml froze fine in Rails 2.1 but on updating to 2.1.1 it
wouldn't work anymore without the patch attached to that ticket.
Evidently Rails is choking on the -2.0.2 in the gem's folder name.

But there seems to be another issue in that ticket, about the
"init.rb" and "rails/init.rb" files not get evaluated in the right
order, from the right place, or at all (the behaviour is

I found that when I tried deploying to the remote server I was
suddenly getting "uninitialized constant Rails::Initializer::Sass"
errors. Turns out that the difference was that my local machine had
2.0.2 installed as a gem system-wide and the remote deployment machine
only had 1.8.2. Once I remove the system-wide copies of the Haml gem I
was able to reproduce the flaw on the local machine too.

Further investigation showed that neither "init.rb" nor "rails/
init.rb" was getting evaluated in the frozen copy of the gem.
Workaround was to move the gem back to vendor/plugins/haml again.

I do have one other gem frozen into vendor/gems/ and that one works
fine even though no other copy is installed system-wide, probably
because that particular gem doesn't depend on anything being done in
"init.rb" or "rails/init.rb".

Would like to see this fixed, but not sure exactly where the fault
lies. Looks to me like it might be a Rails bug if those files aren't
getting evaluated. What do people think?


Reply all
Reply to author
0 new messages