blog.mhartl | Michael Hartl's tech blog

2010-07-28

Deploying to Heroku with Rails 3.0.0.rc

Filed under: Ruby on Rails — mhartl @ 16:34

UPDATE: Heroku now works with the latest Bundler, so this post is (or should be) obsolete.

The Ruby on Rails Tutorial book uses the latest version of Rails, which is the current release candidate of 3.0.0.rc. Unfortunately, at the time of this writing, you can’t deploy applications to Heroku using the Rails release candidate because of a conflict with the latest version of Bundler. Instead of a successful deploy, you get an error like this:

$ git push heroku
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1018 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)

-----> Heroku receiving push
-----> Rails app detected
-----> Detected Rails is not set to serve static_assets
       Installing rails3_serve_static_assets... done
-----> Gemfile detected, running Bundler
       Unresolved dependencies detected; Installing...
       Your Gemfile.lock was generated by Bundler 0.10.
       You must delete it if you wish to use Bundler 0.9.
       FAILED: Have you updated to use a 0.9 Gemfile?
       http://docs.heroku.com/gems#gem-bundler

error: hooks/pre-receive exited with error code 1

Eventually, Heroku support for the Rails release candidate (or perhaps for the final release) will no doubt be ready, but for now you can work around this problem as follows:

$ [sudo] gem uninstall bundler
$ [sudo] gem install bundler -v 0.9.26
$ rm -f Gemfile.lock

Then use this as your Gemfile, which reverts back to Rails 3.0.0.beta4:

source 'http://rubygems.org'

gem 'rails', '3.0.0.beta4'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'

Then install the gems:

$ bundle install

At this point, the push to Heroku should work. (Of course, that doesn’t mean it will. :-)

$ git add .
$ git commit -m "Ready to deploy"
$ git push heroku master
About these ads

20 Comments

  1. This didn’t work for me.
    I want to continue with the new Rails 3 book so I’ve uninstalled the Bundler -v 0.9.26 and reinstalled Bundler –pre. I hope that heroku fixes their dependencies soon so I can deploy my app while following along in the book.
    Thanks for a great resource MH!

    Comment by Jamey Davis — 2010-07-28 @ 18:05

  2. Sorry it didn’t work for you. These sorts of annoyances often happen during Rails upgrade periods. Don’t worry—eventually all the dust will settle (I hope :-).

    Comment by mhartl — 2010-07-28 @ 18:46

  3. You are not specific on what didn’t work, but there is a typo.

    git commit -a “Ready to deploy”

    should be:

    git commit -a -m “Ready to deploy”

    Comment by david clark — 2010-07-29 @ 09:07

  4. one other thing
    I think
    git push heroku
    should be
    git push heroku master

    Comment by david clark — 2010-07-29 @ 09:14

  5. Thanks for catching this! It should have been

    git commit -m "Ready to deploy"

    You could use -am, but the -a is unnecessary if you’ve just done git add .

    For the Heroku push, you have to do

    git push heroku master

    the first time, but subsequent pushes can omit master. You’re right, though; in this context, where the user may not have made a successful push, it’s much safer to use the full command. I’ve updated the post accordingly.

    Comment by mhartl — 2010-07-29 @ 09:31

  6. hello, it works for me after deleting / creating the folder .git for an existing project

    Comment by riface — 2010-07-29 @ 10:54

  7. Didn’t work for me. Hope heroku will fix this soon. I’m new to rails and really excited to try anything.

    Comment by kinopyo — 2010-07-30 @ 10:22

  8. I got this to work to by removing the .git file, uninstalling the newest bundler and then installing the version listed above, updating the gemfile, and then doing the git steps (i.e. git init, etc) over again

    Comment by justin — 2010-07-31 @ 08:22

  9. Also did not work for me.

    i am using the downgraded bundler as suggested. Recreated the Gemfile.lock, commited, then tried to push… and when i try to push to heroku i get:

    $ bundle -v
    Bundler version 0.9.26

    —–> Heroku receiving push
    —–> Rails app detected
    —–> Detected Rails is not set to serve static_assets
    Installing rails3_serve_static_assets… done
    —–> Gemfile detected, running Bundler
    Unresolved dependencies detected; Installing…
    Your Gemfile.lock was generated by Bundler 0.10.
    You must delete it if you wish to use Bundler 0.9.
    FAILED: Have you updated to use a 0.9 Gemfile?
    http://docs.heroku.com/gems#gem-bundler

    Any ideas?

    Comment by Coffee — 2010-07-31 @ 11:29

  10. Bundler 0.9 shouldn’t generate a Gemfile.lock file. After making sure you’ve removed that file, run bundle install again. If Gemfile.lock reappears, it probably means that you still have Bundler 1.0.0.rc somewhere on your system.

    Comment by mhartl — 2010-07-31 @ 14:37

  11. I also got this working by doing the steps above minus the push, then deleting my .git folder and re-doing the git instructions, then ‘git push heroku master’. Great tutorial BTW! Keep up the good work!

    Comment by Dom — 2010-08-1 @ 00:31

  12. I just deleted the .lock gemfile and reverted to rails beta 4 and it worked, no need to delete git files nor install an older version of bundler.

    Of course that doing this requires the tiny management of always deleting the .lock before pushing to heroku, which isn’t that big a deal anyway since it’s just a temporary solution.

    Comment by pedromtavares — 2010-08-1 @ 12:48

  13. Instead of the people saying they had to remove git, and reinitialize it, I did git rm -f Gemfile.lock as well and then it worked

    Comment by Luke — 2010-08-1 @ 23:44

  14. I just ran into this problem with my Sinatra/Padrino app.

    Just make sure that your Gemfile.lock file is not your git snapshot and heroku works fine. The easiest way to do this is to make sure you have a .gitignore file, and a add:
    Gemfile.lock

    If you already created your git repo and added this file, remove it from your repo via “git rm -f Gemfile.lock” (what Luke just said) and make your .gitignore file

    Comment by autodidakto — 2010-08-4 @ 03:05

  15. It looks like Heroku has updated the supported bundler version. I just did a push with 1.0.0.rc.

    Comment by Glen A-B — 2010-08-11 @ 14:37

  16. Thanks. Yeah, I updated the Rails Tutorial news post, but I should make a note here, too.

    Comment by mhartl — 2010-08-11 @ 15:23

  17. thanks!! this was a big help! After researching for an hour or so I finally found this and it solved my problems!

    Comment by Robt — 2010-08-24 @ 20:26

  18. In testing, this worked for me. Thanks. You have solved by hour long problem.

    Comment by PHP Freak — 2010-12-19 @ 01:10

  19. —–> Heroku receiving push
    —–> Ruby/Rails app detected
    —–> Detected Rails is not set to serve static_assets
    Installing rails3_serve_static_assets… done
    —–> Configure Rails 3 to disable x-sendfile
    Installing rails3_disable_x_sendfile… done
    —–> Configure Rails to log to stdout
    Installing rails_log_stdout… done
    —–> Gemfile detected, running Bundler version 1.0.7
    All dependencies are satisfied
    —–> Compiled slug size is 4.4MB
    —–> Launching… done, v7
    http://…………….heroku.com deployed to Heroku

    And I got this on my page :

    Application Error
    An error occurred in the application and your page could not be served. Please try again in a few moments.
    If you are the application owner, check your logs for details.

    What’s the problem?

    Comment by albanvervust — 2011-08-17 @ 01:31

    • I receive the same error, and am not sure how to continue. Any help or guidance would be much appreciated.

      Comment by Lee — 2011-10-19 @ 23:54


RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Customized Shocking Blue Green Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 28 other followers

%d bloggers like this: