“bin/rails: 没有这样的文件或目录"带 Ruby 2 &Heroku 上的 Rails 4
在遵循 Michael Hartl 的 Ruby on Rails 教程,我的应用程序无法在 Heroku 上启动,但使用 bundle exec rails server
在本地运行良好.检查 heroku logs -t
显示以下错误:
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
如果我 heroku run bash
并检查 bin
目录,我可以看到 not rails
> 可执行文件:
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.
在为此苦苦挣扎之后,我注意到我的 Rails 4 项目有一个 /bin
目录,这与一些旧的 Rails 3 不同我克隆的项目./bin
包含 3 个文件,bundle
、rails
和 rake
,但这些文件没有进入 Heroku因为我的全局 .gitignore
文件中有 bin
.
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.
如果您使用 Git 和其他语言(Java 等),这是一个非常常见的忽略规则,因此要解决此问题:
This is a pretty common ignore rule if you work with Git and other languages (Java, etc.), so to fix this:
- 从
~/.gitignore
中删除bin
- 运行
捆绑安装
- 提交您的更改为
git add .
和git commit -m "Add bin back"
- 使用
git push heroku master
将您的更改推送到 Heroku
- Remove
bin
from~/.gitignore
- Run
bundle install
- Commit your
changes with
git add .
andgit commit -m "Add bin back"
- Push your changes to Heroku with
git push heroku master