Roh*_*hit 209 ruby installation rubygems ruby-on-rails
我尝试使用,gem install pg
但它似乎没有用.
gem install pg
给出了这个错误
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
C:/Ruby/bin/ruby.exe 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=C:/Ruby/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 C:/Ruby/lib/ruby/gems/1.8/gems/pg-0.10.1 for
inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/pg-0.10.1/ext/gem_make.out
Run Code Online (Sandbox Code Playgroud)
Dev*_*oop 378
我有这个问题,这对我有用:
安装postgresql-devel包,这将解决pg_config缺失的问题.
sudo apt-get install libpq-dev
Run Code Online (Sandbox Code Playgroud)
Mah*_*tam 84
问题是gem依赖所以在安装pg之前确保你已经安装了"libpq-dev"
Ubuntu系统:
sudo apt-get install libpq-dev
RHEL系统:
yum install postgresql-devel
苹果电脑:
brew安装postgresql
Fla*_*viu 58
gem install pg -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config
cre*_*gox 35
@Winfield 说:
pg gem需要postgresql客户端库进行绑定.此错误通常意味着它无法找到您的Postgres库.要么您没有安装它们,要么您可能需要将它传递
--with-pg-dir=
给您的gem安装.
更重要的是,您只需要--with-pg-config=
安装它.
如果,你有任何机会,你也通过mac上的网站捆绑安装了postgres,它将会在某个地方/Applications/Postgres.app/Contents/Versions/9.3/bin
.
所以,要么你在gem安装上传递它:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
Run Code Online (Sandbox Code Playgroud)
或者您正确设置PATH.由于这可能太多,暂时设置PATH:
export PATH=%PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin/
Run Code Online (Sandbox Code Playgroud)
Las*_*ert 24
我没有安装postgresql,所以我只是用它来安装它
sudo apt-get install postgresql postgresql-server-dev-9.1
Run Code Online (Sandbox Code Playgroud)
在Ubuntu 12.04上.
这解决了它.
更新:
使用最新版本:
sudo apt-get install postgresql-9.3 postgresql-server-dev-9.3
Run Code Online (Sandbox Code Playgroud)
Nik*_*kov 14
这里回答: 无法在Windows上安装pg gem
昨天发布的最新版本的pg(0.10.0)没有Windows原生版本,但如果安装0.9.0,它应该安装二进制文件而不会出现问题.
Dar*_*rme 11
如果您在Mac 上使用Postgres.app,您可以一劳永逸地解决此问题,如下所示:
首先gem uninstall pg
,然后编辑~/.bash_profile
或~/.zshrc
文件或同等学历,并添加:
# PostgreSQL bin path
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
Run Code Online (Sandbox Code Playgroud)
然后bundle install
,gem install pg
两者都应该按预期工作.
$ PATH=$PATH:/Library/PostgreSQL/9.1/bin sudo gem install pg
Run Code Online (Sandbox Code Playgroud)
将9.1替换为系统上安装的版本.