Ruby on rails gem安装pg在Mac El Capitan上不工作
我试图在Mac El Capitan上安装pg Gem,但总是出现以下错误: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/Users/ricardolopes/Developer/homebrew/bin/pg_config Using config values from /Users/ricardolopes/Developer/homebrew/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: --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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby --with-pg --without-pg --enable-windows-cross --disable-windows-cross --with-pg-config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/ --with-pqlib --without-pqlib --with-libpqlib --without-libpqlib --with-ms/libpqlib --without-ms/libpqlib Gem files will remain installed in /Users/ricardolopes/Code/site-noticias/vendor/bundle/ruby/2.0.0/gems/pg-0.18.3 for inspection. Results logged to /Users/ricardolopes/Code/site-noticias/vendor/bundle/ruby/2.0.0/gems/pg-0.18.3/ext/gem_make.out An error occurred while installing pg (0.18.3), and Bundler cannot continue. Make sure that gem install pg -v '0.18.3' succeeds before bundling. 当我尝试时,我得到: Building native extensions. This could take a while... Successfully installed pg-0.18.3 invalid options: -f fivefish (invalid options are ignored) Parsing documentation for pg-0.18.3 Done installing documentation for pg after 3 seconds 1 gem installed 构建本机扩展。这可能需要一段时间。。。 已成功安装pg-0.18.3 无效选项:-f fivefish (忽略无效选项) pg-0.18.3的解析文档 3秒后完成pg的安装文档 已安装1个gem 但是我运行了Ruby on rails gem安装pg在Mac El Capitan上不工作,ruby-on-rails,rubygems,bundle,pg,Ruby On Rails,Rubygems,Bundle,Pg,我试图在Mac El Capitan上安装pg Gem,但总是出现以下错误: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/Users/ricardolopes/Deve
bundle install
,并在本文开头发布了相同的错误
我尝试从brew重新安装PostgresSQL。对于基本Rails应用程序,您可能已经安装了SQLite,但在您的GEM文件中,它可能只是:
gem'sqlite3'
您是否只需要PostgreSQL进行生产?确保您的GEM文件包含以下内容:
小组:生产部
宝石“pg”
结束
另外,请确保您的Gemfile中包含SQLite,以便开发:
小组:发展怎么办
gem'sqlite3'
结束
然后尝试运行捆绑安装
尝试以下操作:
- brew更新
- brew安装postgresql
- sudo gem安装pg-v“版本”
- 这对我很有效:
sudo gem安装pg--with pg config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
如果与9.4不同,请记住将9.4更改为您的postgres版本。您可能是对的,但即使将sqlite3添加到我的开发组中,rails仍坚持安装pg gem
#使用sqlite3作为活动记录gem'sqlite3',group::development
的数据库,并且这样做:group:development do#访问异常页面上的IRB控制台或使用视图中的gem'web console',“~>2.0”gem'sqlite3'#Spring通过让应用程序在后台运行来加快开发速度。阅读更多:https://github.com/rails/spring gem“spring”终端组:生产执行gem“pg”gem“rails_12factor”终端
但没有成功…如果您试图开发一个12因素应用程序,则不建议这样做,因为这会使开发环境和生产环境产生分歧@NateSHolland是对的,你永远不应该为prod和dev使用不同的db引擎,这是个坏主意。我和原来的帖子有同样的问题。我试过了,但没有解决问题。我也尝试了我能找到的一切。和OP一样,我也尝试过用自制软件进行更新和重新安装。没有快乐。这个问题使我的项目完全无限期地停止。在我重新安装计算机后,我又遇到了同样的问题。这在10.11.2上对我起到了作用:sudo su
和env ARCHFLAGS=“-arch x86_64”gem install pg-v'0.18.1'
它在Mac OS X 10.11.6和Bundler版本1.12.5上工作
Building native extensions. This could take a while...
Successfully installed pg-0.18.3
invalid options: -f fivefish
(invalid options are ignored)
Parsing documentation for pg-0.18.3
Done installing documentation for pg after 3 seconds
1 gem installed