bundler: 命令未找到:thin,Heroku部署Rails时出现问题。

12

我的应用在本地机器上运行得很好,我已经成功将其推送到 GitHub 和 Heroku,但当我尝试在浏览器中打开应用程序时,我遇到了以下错误:

Application Error
An error occurred in the application and your page could not be served. Please try again in a few moments.

If you are the application owner, check your logs for details.

然后我尝试运行

$ heroku logs

我在控制台中得到以下输出:

2012-07-05T21:52:11+00:00 heroku[slugc]: Slug compilation started
2012-07-05T21:52:33+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2012-07-05T21:53:33+00:00 heroku[slugc]: Slug compilation started
2012-07-05T21:53:55+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2012-07-05T21:58:45+00:00 heroku[slugc]: Slug compilation started
2012-07-05T21:59:04+00:00 heroku[slugc]: Slug compilation failed: failed to compile Ruby/rails app
2012-07-05T22:00:34+00:00 heroku[slugc]: Slug compilation started
2012-07-05T22:01:21+00:00 heroku[api]: Add shared-database:5mb add-on by aayushgopaldawra@gmail.com
2012-07-05T22:01:21+00:00 heroku[api]: Release v2 created by username@gmail.com
2012-07-05T22:01:21+00:00 heroku[api]: Add RAILS_ENV, LANG, PATH, RACK_ENV, GEM_PATH config by aayushgopaldawra@gmail.com
2012-07-05T22:01:21+00:00 heroku[api]: Release v3 created by username@gmail.com
2012-07-05T22:01:23+00:00 heroku[api]: Release v4 created by username@gmail.com
2012-07-05T22:01:23+00:00 heroku[api]: Deploy 23effb5 by username@gmail.com
2012-07-05T22:01:24+00:00 heroku[slugc]: Slug compilation finished
2012-07-05T22:01:27+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -R config.ru -e production -p 4606`
2012-07-05T22:01:30+00:00 app[web.1]: bundler: command not found: thin
2012-07-05T22:01:30+00:00 app[web.1]: Install missing gem executables with `bundle install`
2012-07-05T22:01:31+00:00 heroku[web.1]: Process exited with status 127
2012-07-05T22:01:31+00:00 heroku[web.1]: State changed from starting to crashed
2012-07-05T22:01:31+00:00 heroku[web.1]: State changed from crashed to starting
2012-07-05T22:01:34+00:00 heroku[web.1]: Starting process with command `bundle exec thin start -R config.ru -e production -p 16779`
2012-07-05T22:01:35+00:00 app[web.1]: bundler: command not found: thin
2012-07-05T22:01:35+00:00 app[web.1]: Install missing gem executables with `bundle install`
2012-07-05T22:01:36+00:00 heroku[web.1]: Process exited with status 127
2012-07-05T22:01:36+00:00 heroku[web.1]: State changed from starting to crashed
2012-07-05T22:01:37+00:00 heroku[router]: Error H10 (App crashed) -> GET glowing-robot-9319.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-07-05T22:01:38+00:00 heroku[router]: Error H10 (App crashed) -> GET glowing-robot-9319.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=
2012-07-05T22:01:49+00:00 heroku[router]: Error H10 (App crashed) -> GET glowing-robot-9319.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-07-05T22:01:49+00:00 heroku[router]: Error H10 (App crashed) -> GET glowing-robot-9319.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=
2012-07-05T22:01:50+00:00 heroku[router]: Error H10 (App crashed) -> GET glowing-robot-9319.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-07-05T22:01:51+00:00 heroku[router]: Error H10 (App crashed) -> GET glowing-robot-9319.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=
2012-07-05T22:01:51+00:00 heroku[router]: Error H10 (App crashed) -> GET glowing-robot-9319.herokuapp.com/ dyno= queue= wait= service= status=503 bytes=
2012-07-05T22:01:51+00:00 heroku[router]: Error H10 (App crashed) -> GET glowing-robot-9319.herokuapp.com/favicon.ico dyno= queue= wait= service= status=503 bytes=

我无法理解这个问题,因为这是我第一次部署到Heroku,我对Web部署一无所知。任何帮助将不胜感激!


Gemfile 中添加 gem 'pg' gem 'taps',然后运行 bundle install。将代码部署到Heroku并重新启动服务器。 - Shamith c
3个回答

21
对我来说问题在于我在开发部分的Gemfile中添加了thin,但是一旦我这样做,heroku就想在生产环境中使用它,但不会安装开发部分的gems。通过将thin gem移出开发部分以供所有环境使用,我能够解决这个错误。
你的Gemfile可能看起来像这样(针对Rails应用):
source 'https://rubygems.org'

gem 'rails'
gem 'heroku'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'pg'
gem 'thin'

# more gems

Heroku建议在生产环境中使用thin作为Web服务器。

更新(2012-05-16):在上面提到的Rails 3 Web服务器链接中,Heroku现在推荐使用unicorn。thin仍然可以工作,但您可能需要考虑切换到unicorn


2

你可能在你的Gemfile中缺少了一个gem。请确保你的应用程序需要的所有内容都在Gemfile中指定,而不是本地执行“gem install”命令。要验证,你可以安装RVM,为你的应用程序创建一个特定的gemset,在你的应用程序目录中运行“bundle install”,然后查看你的应用程序是否在本地运行。如果它无法运行,则肯定缺少一个gem。


1
似乎Heroku在没有Procfile的情况下试图启动Thin。如上所述,Gemfile中未安装Thin,因此出现错误。按上述方法将Thin从开发组中移除即可解决。
如果您想让Heroku启动Unicorn而不是Thin,请按照这里指示设置config/unicorn.rb和Procfile:https://devcenter.heroku.com/articles/rails-unicorn Unicorn的Procfile内容在上面的链接中列出,有关Procfile的更多信息(只是一个名为“ Procfile”的文件,在应用程序的根目录中)在此处:https://devcenter.heroku.com/articles/procfile

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