[英]“Failed to install gems via Bundler” when deploying to Heroku
Background: I'm working through the book "Ruby on Rails 3 Tutorial" by Michael Hartl. 背景:我正在研究Michael Hartl撰写的“ Ruby on Rails 3教程”一书。 I've gotten to the point where I'm setting up heroku.
我已经到了设置heroku的地步。 The text directs me to use sqlite3, but it seems that heroku no longer allows a sqlite3 backend.
文字指示我使用sqlite3,但似乎heroku不再允许sqlite3后端。 So, I'm trying to use postgres instead.
因此,我正在尝试使用postgres。
I'm working on a Mac, OS 10.6.8. 我正在Mac OS 10.6.8上工作。
Problem: I try to do 问题:我尝试做
$ git push heroku master
Then I get 然后我得到
Counting objects: 69, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (55/55), done.
Writing objects: 100% (69/69), 26.69 KiB, done.
Total 69 (delta 5), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.0.rc.2
Running: bundle install --without development:test --path vendor/bundle -- binstubs bin/ --deployment
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
You have added to the Gemfile:
* pg
You have deleted from the Gemfile:
* sqlite3
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
With respect to "Run 'bundle install' elsewhere" -- what does elsewhere mean in this case? 关于“在其他地方运行”捆绑安装” –在这种情况下,其他地方意味着什么? In another directory?
在另一个目录中? I've tried that, to no avail.
我已经尝试过了,但无济于事。 Also there's no Gemfile.lock file to add.
也没有要添加的Gemfile.lock文件。 In summary: I'm confused.
总结:我很困惑。
====== ======
In response to hgmnz: 针对hgmnz:
$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Enter your password to install the bundled RubyGems to your system:
( --- edited out ---)
Installing pg (0.14.0) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /sw/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
( -- edited out --- )
Gem files will remain installed in /Users/adamshaw/.bundler/tmp/14373/gems/pg-0.14.0 for inspection.
Results logged to /Users/adamshaw/.bundler/tmp/14373/gems/pg-0.14.0/ext/gem_make.out
An error occured while installing pg (0.14.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.14.0'` succeeds before bundling.
Then 然后
$ sudo gem install pg -v '0.14.0'
Then 然后
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /sw/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
( --- edited out --- )
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/pg-0.14.0 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/pg-0.14.0/ext/gem_make.out
Hmm, that seems to indicate that you've modified your Gemfile
to include the pg
gem, but haven't run bundle install
(on your dev machine) to lock those gems down. 嗯,这似乎表明您已修改
Gemfile
使其包含pg
gem,但尚未(在开发机器上)运行bundle install
来锁定这些gem。 Running bundle install
will resolve all gem dependencies and generate a new Gemfile.lock
. 运行
bundle install
将解决所有gem依赖项并生成一个新的Gemfile.lock
。 That's the file you should check into git and then attempt the deploy. 那是您应该检入git然后尝试部署的文件。
Run the following on your development machine: 在开发计算机上运行以下命令:
bundle install
git add Gemfile.lock
git commit -m "Locking gems"
git push heroku # assumes default remote named heroku
You need to let the gem installer know where your PostgreSQL installation is located, because it needs to use some of those files when installing. 您需要让gem installer知道PostgreSQL安装的位置,因为在安装时它需要使用其中一些文件。
Check out Error installing pg gem on osx 签出在osx上安装pg gem时出错
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.