59

While following the Rails 4 Beta version of Michael Hartl's Ruby on Rails Tutorial, my app fails to start on Heroku, but runs fine locally with bundle exec rails server. Checking heroku logs -t reveals the following error:

$ heroku[web.1]: State changed from crashed to starting
$ heroku[web.1]: Starting process with command `bin/rails server 
-p 33847 -e $RAILS_ENV`
$ app[web.1]: bash: bin/rails: No such file or directory
$ heroku[web.1]: Process exited with status 127
$ heroku[web.1]: State changed from starting to crashed
$ heroku[web.1]: Error R99 (Platform error) -> Failed to launch the 
dyno within 10 seconds
$ heroku[web.1]: Stopping process with SIGKILL

If I heroku run bash and check the bin directory, I can see that there is not a rails executable:

~$ ls bin
erb  gem  irb  node rdoc  ri  ruby  testrb

What have I done wrong? I followed the tutorial exactly.

8 Answers 8

105

I had this problem also since I upgraded to rails 4.0.0

Run this command

rake rails:update:bin

You can go here for more info https://devcenter.heroku.com/articles/rails4

4
  • 2
    Good info for those that are upgrading from Rails 3, etc., but the problem in the question occurred in a new application. Also, this won't help you if you have those directories gitignored, because they still won't get git pushed to Heroku. Aug 21, 2013 at 19:41
  • 2
    Moving to Rails 4.0.0, this was definitely the problem. Sep 28, 2013 at 0:46
  • Issuing this command helped me getting my heroku app running again. Thanks a lot. Dec 13, 2014 at 6:40
  • rake app:update:bin for Rails 6+ as of this writing
    – Victor S
    Dec 5, 2021 at 0:03
40

After struggling with this for a bit, I noticed that my Rails 4 project had a /bin directory, unlike some older Rails 3 projects I had cloned. /bin contains 3 files, bundle, rails, and rake, but these weren't making it to Heroku because I had bin in my global .gitignore file.

This is a pretty common ignore rule if you work with Git and other languages (Java, etc.), so to fix this:

  1. Remove bin from ~/.gitignore
  2. Run bundle install
  3. Commit your changes with git add . and git commit -m "Add bin back"
  4. Push your changes to Heroku with git push heroku master
6
  • 3
    There is a Heroku guide on running Rails4 applications on Heroku - devcenter.heroku.com/articles/rails4 Jul 11, 2013 at 7:23
  • 1
    Yep, it mentions not having bin in your .gitignore, but the tutorial doesn't. Just thought I would create this in case someone else has a similar problem. Jul 11, 2013 at 12:45
  • @justingarrick do you really need to run bundle install? Seems like an extra step.
    – Josh
    Nov 18, 2013 at 2:42
  • Make sure it's not in your global gitignore. That's what bit me.
    – courtsimas
    Jun 17, 2014 at 20:20
  • I had the same problem for Dokku: 502 bad gateway. Thanks for the help. Aug 15, 2014 at 12:28
9

Steps :

  1. bundle config --delete bin # Turn off Bundler's stub generator

  2. rake rails:update:bin # Use the new Rails 4 executables

  3. git add bin or git add bin -f # Add bin/ to source control

  4. git commit -a -m "you commit message"

  5. git push heroku master

  6. heroku open

0
3

I had this issue because the permissions on my ~/bin directory were 644 instead of 755. Running rake rails:update:bin locally (on Mac/*nix) and then pushing the changes fixed the problem.

1

I had the very same problem that you did. The issue lied in the fact that the bin folder was never pushed to the heroku repository.

I looked, I looked, and then I looked again, there was no rule in the .gitignore file for the bin/ folder...

Then, after a lot of pain and anguish, I realized that a couple of months before I had created a global .gitignore that would ignore all bin folders of all my repositories (why lord, why??).

I deleted the global .gitignore, and everything worked fine.

0

We didn't have a myapp/bin directory in our rails 4 app, so we created one and then copied in the my app/script/rails file, plus the bundle and rake files from under rvm/ruby/bin and then added these to the repo for git and pushed it up to heroku and all was well.

0

On rails 5.2.6, rake app:update:bin worked for me. Now deployment to heroku is working.

-1

I can confirm running rake rails:update:bin works, as said by @Ryan Taylor.

I think I had this problem because I originally created this Rails app on Windows. Running the command above on Linux solved for me.

Also, on changing from Windows to Linux for development, it is a good idea to delete Gemfile.lock file and run bundle install to generate it again without Windows specific gems listed there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.