我想在本地使用PostgreSQL在Ruby on Rails中开发,所以我试图安装pg gem。在Ubuntu 12.04上。在终端,我输入:无法安装pg gem,在-lpq中检查PQconnectdb()... no
gem install pg -v '0.12.2'
会抛出以下错误:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/home/troyshu/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/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
--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=/home/troyshu/.rvm/rubies/ruby-1.9.3-p194/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
--with-pqlib
--without-pqlib
--with-libpqlib
--without-libpqlib
--with-ms/libpqlib
--without-ms/libpqlib
Gem files will remain installed in /home/troyshu/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.14.1 for inspection.
Results logged to /home/troyshu/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.14.1/ext/gem_make.out
有趣的是,增加了sudo来命令作品:
$ sudo gem install pg -v '0.12.2'
Building native extensions. This could take a while...
Successfully installed pg-0.12.2
1 gem installed
顺便说一句,我不得不跑“ sudo apt-get install ruby1.9.1-dev“来获得上述命令的工作。但我仍然无法做任何开发,因为“捆绑安装”将不起作用(并一直告诉我运行'gem install pg -v'0.12.2')
我有一种感觉,“gem install pg”是越来越绊倒在
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
但是,作为一个完整的小白到Ubuntu和RoR的,我不知道为什么。也许我的搜索技能也很糟糕,因为我一直无法找到解决方案,我的个案。希望有一个修复?
谢谢!
你确定'的libpq-dev'安装?我已经发布了解释如何这样做的答案。 –
您安装了哪些版本的PostgreSQL和'libpq-dev'? –
因此,我只是安装了一个Ubuntu 12.04 Vagrant框,并以非root用户身份运行以下命令:'$ sudo apt-get update','$ sudo apt-get install postgresql libpq-dev build-essentials git-core curl' ,'$ curl -L https://get.rvm.io | bash -s stable --ruby'和'$ gem install pg -v'0.12.2'没有错误(另外,我安装了最新版本的'pg' gem,v0.14.1,没有错误;你可能想要看看你是否可以使用最新版本,而不是它必须解决你的问题)。 –