Postgresql gem安装pg——pg配置工作时,捆绑包失败
运行时(作为根目录) 我得到以下输出:Postgresql gem安装pg——pg配置工作时,捆绑包失败,postgresql,rubygems,bundler,pg,Postgresql,Rubygems,Bundler,Pg,运行时(作为根目录) 我得到以下输出: #-> gem instal pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config Building native extensions. This could take a while... Successfully installed pg-0.12.0 1 gem installed Installing ri documentation for pg-0.12.0..
#-> gem instal pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config
Building native extensions. This could take a while...
Successfully installed pg-0.12.0
1 gem installed
Installing ri documentation for pg-0.12.0...
Installing RDoc documentation for pg-0.12.0...
#->
当我运行bundle安装时:
Installing pg (0.12.0) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.2-p290/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
--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=/usr/local/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
Gem files will remain installed in /var/www/simpletrac/vendor/cache/ruby/1.9.1/gems/pg- 0.12.0 for inspection.
Results logged to /var/www/simpletrac/vendor/cache/ruby/1.9.1/gems/pg-0.12.0/ext/gem_make.out
An error occured while installing pg (0.12.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.12.0'` succeeds before bundling.
我已将libpq fe.h安装在/usr/pgsql-9.1/include/libpq fe.h。所以,我试过了
gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config --with-pg-lib=/usr/pgsql-9.1/include/libpq-fe.h but still no go.
任何帮助都将不胜感激
此外,我还安装了postgresql91-devel和ruby-devel。正在运行CentOS 6。在运行
捆绑安装之前,您是否尝试过运行此功能
bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config
请参阅如果有人使用macports安装postgres,并且在查找其pg_配置时遇到问题,请尝试以下操作:
bundle config build.pg --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config
我希望这有助于节省一些时间。干杯 如果安装了pg_config,但它不在任何路径中,则可能会出现此错误。您可以将其添加到~/.bashrc中的路径环境中
比如说
export PATH=${PATH}:/usr/pgsql-9.2/bin
brew install postgresql
通过安装libpq-dev修复了相同的问题
参考:我必须这样做才能在OS X上修复我的问题:
export PATH=/opt/local/lib/postgresql84/bin/:$PATH
我必须这样做,尽管事实上我已经在我的道路上:
[user@foo ~] which psql84
/opt/local/bin/psql84
[user@foo ~] ls -altrh /opt/local/bin/psql84
lrwxr-xr-x 1 root admin 36B Dec 7 02:15 /opt/local/bin/psql84 -> /opt/local/lib/postgresql84/bin/psql
我希望这能帮助其他Mac用户解决这个问题。试试这个:
yum install libpqxx-devel
它适用于Postgr9.2。Postgres gem无法找到Postgres配置文件。你需要告诉它在哪里。在我看来,最令人愉快的解决方案是跳过Brew和MacPorts,只使用Postgres应用程序。从此处下载并安装:
现在将bin文件夹添加到您的路径:
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
您可能还希望将其添加到~/.bash_配置文件中
现在安装gem:
gem install pg
它应该会顺利进行。我在Mac上,我使用自制软件,所以为了解决这个问题,我刚刚用brew安装了postgresql:
brew install postgresql
然后安装了gem
gem install pg -v '0.17.1'
我用的是Arch Linux,也有类似的问题。使用sudopacman-slibpqxx
并重新运行,然后安装pg gem,然后再次运行bundle install
,这一次终于成功了 这建议使用:
gem install pg --pre
我好几天都无法安装pggem
,但这种方法最终对我有效。希望这会有所帮助。如果您不确定pg_配置在哪里,并且假设您在Linux或Mac上,您可以运行以下命令:
which pg_config
这将返回==>/usr/pgsql-9.1/bin/pg_config
现在将此路径用作
bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config
现在完成捆绑安装
什么时候在Mac上使用postgresapp,阅读文档并配置$PATH。在此之前,请再次尝试运行捆绑包安装。复制并粘贴:
bundle config build.pg——其中pg config=`which pg_config`&&bundle
细节: 有关更多信息,请访问:
确保已安装postgress。如果没有,请先安装它。以终端为例
export PATH=${PATH}:/usr/pgsql-9.2/bin
brew install postgresql
在那次跑步之后
bundle install
UBUNTU上的一些案例
sudo apt-get install libpq-dev
在CentOS 7
sudo yum install postgresql-devel
然后
这对我很有用。在OSX中,首先安装pg:
brew install postgresql
第二,安装gem:
gem install pg --source 'https://rubygems.org/'
然后,您可以运行
捆绑安装我正在使用mac,不想在本地安装postgresql
安装libpq并设置绑定器配置对我很有用
如果您使用的是MacOS+MacPorts,请参阅Lester的帖子了解解决方案。我也有同样的错误,但我使用的是mysql数据库。请问命令是什么?这似乎有MySql的答案:在CentOS 6上像一个魔咒一样工作!在整个安装完全成功之前,还需要运行一个yum安装postgresql-devel
!另外,--with pg dir=/usr/pgsql-
处理配置和库。这可能是从源代码而不是包管理器安装的结果吗?不管怎么说,这对我很有用——只是好奇为什么我会遇到这个问题。我也在使用Arch Linux,这解决了我的问题!2016年,postgresql 9.5和pg 0.18.4似乎与上述解决方案不兼容(我也在使用arch linux)。感谢我在Mac Yosemite上测试了此解决方案。