无法在Mountain Lion上安装pg gem [英] Can't install pg gem on Mountain Lion
问题描述
升级到Mountain Lion后,我在Rails上遇到了很多麻烦.
I have been having a lot of troubles with Rails after upgrading to Mountain Lion.
到目前为止,尝试解决这些问题并在Internet上搜索了数小时,以确保升级后我的系统具有运行rails的所有依赖项:
Trying to trouble shoot these and searching for hours on the internet so far I have done the following to ensure my system has all the dependencies to run rails after the upgrade:
- 我更新了Homebrew安装程序
- 我更新了RVM安装
- 我安装了XCode命令行工具
- 我安装了GCC 如前所述
- 我将Ruby版本升级到了
- I updated my Homebrew installation
- I updated my RVM installation
- I installed the XCode command line tools
- I installed GCC as mentioned
- I upgraded my version of Ruby to
红宝石1.9.2p290(2011-07-09修订版32553)[x86_64-darwin10.8.0]
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
I also found out that Mountain Lion has some issues with Postgres so I saw this post and found out that I need to add this line to my Bash profile:
export PATH="/usr/local/bin:/usr/bin:$PATH"
现在,我进入升级前曾在Snow Leopard上正常运行的Rails应用程序,当我在命令行上运行rails s
时,出现以下错误:
Now I go to my Rails app that used to run fine on Snow Leopard before I upgraded, and when I run rails s
at the command line I get the following error:
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应用程序并尝试bundle install
时,它在pg安装中失败.
When I go to the Rails app and try bundle install
it fails at pg installation.
推荐答案
从 http://www.enterprisedb.com/products-services-training/pgdownload#osx
,然后使您的路径看起来像这样:
and then make your path look something like this:
PATH=$PATH:/Library/PostgreSQL/9.0/bin/ gem install pg
可以!
注意:请在路径中正确指定您的postgreSQL安装版本.
Note: Please specify your postgreSQL installed version correctly in the path.
在带有Homebrew的OS X上:
-
使用以下命令安装postgresql:
Install postgresql using:
brew install postgresql
然后使用以下命令安装gem:
Then install the gem using:
gem install pg -- --with-pg-config=/usr/local/bin/pg_config
在具有MacPorts的OS X上:
gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
希望这会有所帮助!
这篇关于无法在Mountain Lion上安装pg gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!