Sunday, January 2, 2011

Rails 2.3.5 App adding Bundler on Heroku

After staying up a little later than usual, I pushed the latest ASX value screener code to heroku - only for it to be rejected as now bundler was being used for everything. Bugger.

If you are following the instructions on converting a 2.3.5 rails app to use bundler and you get an error like this:

$ rake db:migrate --trace
(in ...)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant Rails::Boot::Bundler
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in `const_missing'

You have probably misspelt preinitialize.rb in your config directory. Correct it and ensure that it is added into your git and you will get rid of this error.

Uploading to heroku was where the next trap lay in wait:

$ git push heroku master
Counting objects: 24, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (17/17), done.
Writing objects: 100% (17/17), 5.86 KiB, done.
Total 17 (delta 12), reused 0 (delta 0)

-----> Heroku receiving push
-----> Rails app detected
-----> Gemfile detected, running Bundler version 0.9.9
-----> Bundler works best on the Bamboo stack.  Please migrate your app:
       http://docs.heroku.com/bamboo
       Unresolved dependencies detected; Installing...
       /usr/local/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 2, col 8: `  specs:' (ArgumentError)
           from /usr/local/lib/ruby/1.8/yaml.rb:133:in `load'

To avoid this, switch to the bamboo stack as recommended and bundler will work as expected.

Eventually, site back up - off to bed.