ruby-on-rails – 无法在Mountain Lion上安装pg gem

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 无法在Mountain Lion上安装pg gem前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
升级到Mountain Lion后,我遇到了很多关于Rails的麻烦.

到目前为止,我试图在互联网上搜索这些并搜索几个小时,以确保我的系统具有升级后运行rails的所有依赖关系:

>我更新了我的Homebrew安装
>我更新了我的RVM安装
>我安装了XCode命令行工具
>我安装了GCC as mentioned
>我将我的Ruby版本升级

ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]

>我的Rails版本被验证为Rails 3.2.6
>我还发现Mountain Lion与Postgres有一些问题,所以我看到了this post,发现我需要将这一行添加到我的Bash配置文件中:

export PATH="/usr/local/bin:/usr/bin:$PATH"

现在我转到我升级之前在Snow Leopard上运行正常的Rails应用程序,当我在命令行运行rails时,我收到以下错误

AM@~/Documents/RailsWS/app0815 >gem install pg
 Building native extensions.  This could take a while...
 ERROR:  Error installing pg:
 ERROR: Failed to build gem native extension.
 /Users/AM/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
 checking for pg_config... yes
 Using config values from /usr/bin/pg_config
 checking for libpq-fe.h... *** 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
--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/AM/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
 /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': 
 The complier Failed to generate an executable file. (RuntimeError)
 You have to install development tools first.
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:452:in `try_cpp'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:853:in `block in   find_header'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:280:in `block (2  levels) in postpone'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:254:in `open'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
from /Users/AM/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/mkmf.rb:852:in `find_header'
from extconf.rb:41:in `<main>'


 Gem files will remain installed in /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.14.1 for inspection.
 Results logged to /Users/AM/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.14.1/ext/gem_make.out

当我转到Rails应用程序并尝试捆绑安装时,它在pg安装时失败.

解决方法

http://www.enterprisedb.com/products-services-training/pgdownload#osx下载postgressql安装程序

然后让你的路径看起来像这样:

PATH=$PATH:/Library/Postgresql/9.0/bin/ gem install pg

这样做!

注意:请在路径中正确指定postgresql安装版本.

更新(2015年11月10日)(摘自Heroku)

在OS X上使用Homebrew:

>使用以下命令安装postgresql

brew安装postgresql
>然后使用以下命令安装gem:

gem install pg – –with-pg-config = /usr/local / bin / pg_config

在OS X上使用MacPorts:

gem install pg – –with-pg-config = / opt / local / lib / postgresql84 / bin / pg_config

希望这可以帮助!

猜你在找的Ruby相关文章