Rails Heroku - 错误代码H10 bash: bin/rails: 没有那个文件或目录

3

我正在尝试跟随Michael Hartl的Rails教程,在第7.29步骤中添加身份验证(http://ruby.railstutorial.org/chapters/sign-up#top)。我的项目在本地运行良好,但是当我尝试部署到Heroku时,我收到“应用程序发生错误,无法提供页面”的错误。这是我的日志错误:

     heroku[api]: Starting process with command `bundle exec rake db:migrate` by connorleech@gmail.com
     heroku[run.1285]: Awaiting client
     heroku[run.1285]: Starting process with command `bundle exec rake db:migrate`
     heroku[run.1285]: State changed from starting to up
     heroku[run.1285]: Process exited with status 0
     heroku[run.1285]: State changed from up to complete
     heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=jason-shark-rails-project.herokuapp.com fwd="41.74.174.50" dyno= connect= service= status=503 bytes=
     heroku[web.1]: State changed from crashed to starting
     heroku[web.1]: Starting process with command `bin/rails server -p 10431 -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

看起来我的项目在部署时可能缺少某些东西... bash: bin/rails: 没有那个文件或目录

为什么我的应用程序在本地运行良好,但在部署到Heroku时无法工作?


请查看此线程:https://dev59.com/GWMm5IYBdhLWcg3wVdt5 - konsolebox
您的问题实际上是一个重复的问题,我认为关闭这个问题会更好。 - konsolebox
这个也很有帮助:https://dev59.com/7GMm5IYBdhLWcg3wfu42,来自Heroku网站的信息(https://devcenter.heroku.com/articles/rails4)建议运行rake rails:update:bin。然而,这对我仍然没有用 :( - Connor Leech
你尝试过 heroku config:set PATH=bin:vendor/bundle/ruby/2.0.0/bin:/usr/local/bin:/usr/bin:/bin 吗?其中的 ruby/2.0.0/ 部分应根据您的机器上存在的版本而变化。 - konsolebox
2个回答

5
Rails 4项目有一个/bin目录,不同于我克隆的一些旧的Rails 3项目。/bin包含3个文件:bundlerailsrake,但这些文件没有传送到Heroku,因为我在全局的.gitignore文件中有bin。如果您使用Git和其他语言(如Java)工作,则这是一种常见的忽略规则,因此要解决此问题,您需要执行以下操作:
  1. ~/.gitignore中删除bin
  2. 运行bundle install
  3. 使用git add .git commit -m "Add bin back"提交更改
  4. 使用git push heroku master将更改推送到Heroku

0

我曾经遇到过类似的问题,不知道为什么/bin文件夹没有复制到我的GitHub存储库中(请检查您的存储库?)。在尝试了许多其他无效的解决方案之后,我运行了git add bin,这使我能够将bin文件夹推送到GitHub。我仍然不确定为什么我必须特别为bin文件夹做出这个例外。在Linux上运行Ruby v2,Rails v4。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接