如何使用 pg gemfile 和 Rails 3.1 修复此 Heroku 错误?
我正在尝试将 Rails 3.1 应用程序(带有 CoffeeScript)上传到 Heroku。显然,这存在已知问题 (http://stackoverflow.com/questions/6075961/problem-deploying-rails-3-1-project-to-heroku-could-not-find-a-javascript-runtim),所以我将其添加到我的 Gemfile 中:
group :production do
gem 'therubyracer-heroku', '0.8.1.pre3'
end
然后,经过一番折腾后,我发现我必须执行以下操作:
group :production do
gem 'therubyracer-heroku', '0.8.1.pre3'
gem 'pg'
# pg from http://stackoverflow.com/questions/6410623/heroku-error-when-launch-rails3-1-app-missing-postgres-gem
end
现在我遇到了此错误:“您在开发中修改了 Gemfile,但没有检查生成的快照 (Gemfile.lock)进入版本控制”
git push heroku master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 402 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
-----> Heroku receiving push
-----> Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile
Installing rails3_disable_x_sendfile... done
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Gemfile detected, running Bundler version 1.0.7
Unresolved dependencies detected; Installing...
Using --without development:test
You have modified your Gemfile in development but did not check
the resulting snapshot (Gemfile.lock) into version control
You have added to the Gemfile:
* pg
FAILED: http://devcenter.heroku.com/articles/bundler
! Heroku push rejected, failed to install gems via Bundler
好吧,即使在我运行捆绑更新之后,也没有更新的 Gemfile.lock 需要提交。这是怎么回事?我到底该如何部署到 Heroku?我认为 Ruby on Rails 和 Heroku 应该很容易上手!
I'm trying to upload a Rails 3.1 app (with CoffeeScript) to Heroku. Apparently, there are known issues with this
(http://stackoverflow.com/questions/6075961/problem-deploying-rails-3-1-project-to-heroku-could-not-find-a-javascript-runtim), so I added this to my Gemfile:
group :production do
gem 'therubyracer-heroku', '0.8.1.pre3'
end
Then, after a few more messing around, I found out I had to do the following:
group :production do
gem 'therubyracer-heroku', '0.8.1.pre3'
gem 'pg'
# pg from http://stackoverflow.com/questions/6410623/heroku-error-when-launch-rails3-1-app-missing-postgres-gem
end
Now I hit this error: "You have modified your Gemfile in development but did not check the resulting snapshot (Gemfile.lock) into version control"
git push heroku master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 402 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
-----> Heroku receiving push
-----> Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile
Installing rails3_disable_x_sendfile... done
-----> Configure Rails to log to stdout
Installing rails_log_stdout... done
-----> Gemfile detected, running Bundler version 1.0.7
Unresolved dependencies detected; Installing...
Using --without development:test
You have modified your Gemfile in development but did not check
the resulting snapshot (Gemfile.lock) into version control
You have added to the Gemfile:
* pg
FAILED: http://devcenter.heroku.com/articles/bundler
! Heroku push rejected, failed to install gems via Bundler
Well, there is no updated Gemfile.lock to commit... even after I run bundle update. What's going on? How the heck do I deploy to Heroku? I thought Ruby on Rails and Heroku were supposed to be easy to get started with!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有趣的时机,因为我最近能够将 Rails 3.1 应用程序部署到 Heroku。首先,确保 Gemfile.lock 确实已签入版本控制。然后,考虑使用这个:
这对我来说非常有效,而且我也使用“pg”gem。现在,我从来没有遇到过你犯的错误 - 但我确实知道我上面指定的“therubyracer”gem 会处理 Heroku(或者可能是 Sprockets)方面的 JS 错误。
祝你好运。
Interesting timing because I recently was able to deploy a Rails 3.1 app to Heroku. First off, make sure that the Gemfile.lock is indeed checked into version control. Then, consider using this:
This worked for me perfectly, and I too use the 'pg' gem. Now, I never got the error you did - but I do know that the 'therubyracer' gem I specified above takes care of a JS error on Heroku's (or maybe Sprockets'?) side.
Good Luck.