“bin/rails: No such file or directory” w/ Ruby 2 & Rails 4 on Heroku

前端 未结 7 579
走了就别回头了
走了就别回头了 2020-11-28 07:14

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

相关标签:
7条回答
  • 2020-11-28 07:45

    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 讨论(0)
  • 2020-11-28 07:49

    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 讨论(0)
  • 2020-11-28 07:53

    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
    0 讨论(0)
  • 2020-11-28 07:57

    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.

    0 讨论(0)
  • 2020-11-28 07:58

    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

    0 讨论(0)
  • 2020-11-28 07:58

    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.

    0 讨论(0)
提交回复
热议问题