Ruby on rails &引用;未能通过Bundler安装gems“;部署到Heroku时
背景:我正在阅读迈克尔·哈特尔的《RubyonRails 3教程》。我已经到了要建立heroku的地步。文本指示我使用sqlite3,但heroku似乎不再允许使用sqlite3后端。所以,我试着用postgres来代替 我正在使用Mac操作系统10.6.8 问题:我试着去做Ruby on rails &引用;未能通过Bundler安装gems“;部署到Heroku时,ruby-on-rails,macos,heroku,Ruby On Rails,Macos,Heroku,背景:我正在阅读迈克尔·哈特尔的《RubyonRails 3教程》。我已经到了要建立heroku的地步。文本指示我使用sqlite3,但heroku似乎不再允许使用sqlite3后端。所以,我试着用postgres来代替 我正在使用Mac操作系统10.6.8 问题:我试着去做 $ git push heroku master 然后我得到 Counting objects: 69, done. Delta compression using up to 2 threads. Compressin
$ git push heroku master
然后我得到
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
关于“在别处运行‘bundle安装’”——在这种情况下,别处意味着什么?在另一个目录中?我试过了,没用。此外,没有要添加的Gemfile.lock文件。总之:我很困惑
======
针对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.
然后
然后
嗯,这似乎表明您已经修改了
Gemfile
以包含pg
gem,但还没有运行bundle install
(在您的开发机器上)来锁定这些gem。运行bundle install
将解析所有gem依赖项并生成一个新的Gemfile.lock
。这就是您应该签入git并尝试部署的文件
在开发计算机上运行以下操作:
bundle install
git add Gemfile.lock
git commit -m "Locking gems"
git push heroku # assumes default remote named heroku
嗯,这似乎表明您已经修改了
Gemfile
以包含pg
gem,但还没有运行bundle install
(在您的开发机器上)来锁定这些gem。运行bundle install
将解析所有gem依赖项并生成一个新的Gemfile.lock
。这就是您应该签入git并尝试部署的文件
在开发计算机上运行以下操作:
bundle install
git add Gemfile.lock
git commit -m "Locking gems"
git push heroku # assumes default remote named heroku
您需要让gem安装程序知道您的PostgreSQL安装位置,因为它需要在安装时使用其中一些文件
签出您需要让gem安装程序知道您的PostgreSQL安装位置,因为它需要在安装时使用其中一些文件
退房谢谢。我最终通过从源代码安装postgres(在使用fink、port和EnterpriseDB安装并随后卸载之后)并运行sudo env ARCHFLAGS=“-arch x86_64”gem install pgThank you实现了这一点。我最终通过从源代码安装postgres(在使用fink、port和EnterpriseDB安装并随后卸载后)并运行sudo env ARCHFLAGS=“-arch x86_64”gem install pg来实现这一点
bundle install
git add Gemfile.lock
git commit -m "Locking gems"
git push heroku # assumes default remote named heroku