新的Mavericks更新后,Ruby Bundle安装/更新

时间:2013-11-05 03:20:05

标签: ruby-on-rails ruby macos gem osx-mavericks

我尝试在Mac上更新Mavericks后运行bundle install / bundle update,但是我收到以下错误。有什么想法吗?

我正在使用RVM管理所有内容。

Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.1.0) 
Using i18n (0.6.5) 
Using multi_json (1.8.2) 
Using activesupport (3.2.1) 
Using builder (3.0.4) 
Using activemodel (3.2.1) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.5) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.3) 
Using tilt (1.4.1) 
Using sprockets (2.1.3) 
Using actionpack (3.2.1) 
Using mime-types (1.25) 
Using polyglot (0.3.3) 
Using treetop (1.4.15) 
Using mail (2.4.4) 
Using actionmailer (3.2.1) 
Using arel (3.0.2) 
Using tzinfo (0.3.38) 
Using activerecord (3.2.1) 
Using activeresource (3.2.1) 
Using bcrypt-ruby (3.0.1) 
Using coffee-script-source (1.6.3) 
Using execjs (2.0.2) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.3) 
Using json (1.8.1) 
Using rdoc (3.12.2) 
Using thor (0.14.6) 
Using railties (3.2.1) 
Using coffee-rails (3.2.2) 
Using jquery-rails (3.0.4) 
Installing pg (0.17.0) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/robin/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb 

checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/robin/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
    --with-pg
    --without-pg
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/


Gem files will remain installed in /Users/robin/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.17.0 for inspection.
Results logged to /Users/robin/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.17.0/ext/gem_make.out

An error occurred while installing pg (0.17.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.0'` succeeds before bundling.

所以是的,我无法弄清楚问题。我想下载PostgreSQL gem吗?我已经从XCode获得了命令行工具。

2 个答案:

答案 0 :(得分:0)

如果你使用的是Homebrew,这就可以解决问题:

  • xcode-select --install
  • brew update
  • brew重新安装/安装postgresql

然后你就可以从Gemfile

安装pg了

答案 1 :(得分:0)

对于那些阅读本文的人,以及使用Xcode 5的Mavericks,那么你必须获得Xcode 5的命令行工具才能获得宝石。运行xcode-select --install可能无法检索全新Xcode的命令行工具。转到Apple Developer site,然后转到下载。您可能必须注册为Apple Developer。下载: Xcode的命令行工具(OSX Mavericks) - 十月下旬

另外,我建议使用Postgres.app。也下载。如果您在系统中潜伏着它们,请卸载并删除之前安装的任何Postgres。安装后,请确保您可以通过调用psql或命令which psql从命令行运行PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"。如果你已经安装了Postgres,你应该拥有它。如果您无法调用它,则可能需要将其添加到PATH变量中,如下所示:

PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH"

(在我的系统上,我下载了最新的Postgres.app,所以我的路径变量是:

gem install pg

将它放在你的.bash_profile中,这样你就可以在终端中访问它了。有关在Mac,Linux或Windows上设置Postgres的精彩参考,请参阅this documentation from Heroku

最后,你应该能够获得gem:

{{1}}

对于那些从Sqlite切换到Postgres的人,我也建议this documentation from Heroku as well