“bin/rails: 没有这样的文件或目录"带 Ruby 2 &Heroku 上的 Rails 4 [英] "bin/rails: No such file or directory" w/ Ruby 2 & Rails 4 on Heroku

查看:26
本文介绍了“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 个文件,bundlerailsrake,但这些文件没有进入 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:

  1. ~/.gitignore中删除bin
  2. 运行捆绑安装
  3. 提交您的更改为 git add .git commit -m "Add bin back"
  4. 使用 git push heroku master
  5. 将您的更改推送到 Heroku
  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

这篇关于“bin/rails: 没有这样的文件或目录"带 Ruby 2 &Heroku 上的 Rails 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆