[英]PostgreSQL gem pg was unable to install
我的數據庫是PostgreSQL。我在CENTOS上。...在安裝pg gem時,出現以下錯誤。 我也重新安裝以清除YAML問題,該問題不起作用,但這只是一個警告。 我的主要問題是pg gem的安裝:
[root@vdimc04 ~]# gem install pg
/usr/local/lib/ruby/1.9.1/yaml.rb:56:in `<top (required)>':
It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/local/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
--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=/usr/local/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 /usr/local/lib/ruby/gems/1.9.1/gems/pg-0.14.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.9.1/gems/pg-0.14.1/ext/gem_make.out
我也嘗試使用以下命令,但沒有用:
gem install pg -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config
我在Centos上遇到了同樣的錯誤。 通過谷歌搜索,我找到了兩個要使用的命令:
yum install postgresql-libs
它給我消息說,它已經安裝了。 yum install postgresql-devel
devel-解決了我與pg_config
有關的錯誤,該錯誤用於安裝'pg'.gem。 希望能幫助到你 :)
apos寫道:在Ubuntu 14.04上安裝:
apt-get install postgresql-server-dev-9.3 libpq-dev
這是我在CentOS上啟動並運行PostgreSQL,RVM,Ruby,Rails的食譜
首先,按照http://wiki.postgresql.org/wiki/YUM_Installation上的說明安裝PostgreSQL:
sudo vi /etc/yum.repos.d/CentOS-Base.repo
[base]
exclude=postgresql*
[updates]
exclude=postgresql*
獲取最新的PGDG RPM文件(適用於您的平台/體系結構),例如:
curl -O http://yum.postgresql.org/9.2/redhat/rhel-latest-x86_64/pgdg-redhat92-9.2-7.noarch.rpm
然后
sudo rpm -ivh pgdg-redhat92-9.2-7.noarch.rpm
sudo yum install -y postgresql92-server postgresql92-devel
初始化數據庫:
sudo service postgresql-9.2 initdb
根據需要配置/var/lib/pgsql/9.2/data/postgresql.conf
和/var/lib/pgsql/9.2/data/pg_hba.conf
。
啟動PostgreSQL服務器:
sudo service postgresql-9.2 start
sudo yum -y groupinstall "Development Tools"
sudo yum -y install zlib zlib-devel sqlite-devel httpd curl-devel httpd-devel apr-devel apr-util-devel mlocate man libxml2-devel libxslt-devel libffi-devel readline-devel
注意, 不是 root:
\curl -L get.rvm.io | sudo bash -s stable
注銷並重新啟動。 之后, which rvm
應該以/usr/local/rvm/bin/rvm
並type rvm|head -1
應該說rvm is a function
。
rvm install 1.9.3 --with-openssl-dir=/usr
rvm use 1.9.3 --default
gem install rake
gem install rails
gem install pg -- --with-pg-config=/usr/pgsql-9.2/bin/pg_config
我最新安裝的CentOS需要--with-pg-config
,否則, gem install pg
無法找到pg_config
。 YMMV,但是如果您遵循以上所有內容(在過去幾個月中我已經做了足夠的幾次),請告訴我是否有任何事情令您失望。
嘗試通過以下方式安裝libpq軟件包:
sudo apt-get install libpq-dev
該軟件包有助於pg gem,在那之后你應該沒事的:)
試試看,答案不是我的,但對我有用。 請記住指向您的Postgres.app應用程序在哪里:
bundle config build.pg --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
然后做
bundle update
bundle install
$ sudo apt-get install libpq-dev
$ sudo apt-get install libdbd-pg-ruby1.8
然后:
$ sudo apt-get install pg
對於CentOS,請閱讀以下鏈接。
http://wiki.postgresql.org/wiki/YUM_Installation
在centOS中安裝pg
run this commands
bundle config build.pg
gem install pg -v '0.12.0'
嘗試安裝postgresql服務器和相應的庫。 然后安裝pg gem。 那對你有用
我的問題是在已安裝pg gem之前。但是它沒有加載到捆綁包中。現在解決方案是:當我們聲明像“ rails new Demo”這樣的新應用程序時,我們必須包括
'--database = postgresql'。 所以現在的總命令是:'rails new Demo --database = postgresql'
然后pg gem文件將被捆綁。
捆綁銷售中只有一顆寶石可以存儲。 pg寶石或sqlite3寶石。
現在,相應地編輯database.yml文件。
我遇到了同樣的問題,我嘗試安裝所有依賴項,但都沒有用。 最后,我嘗試使用PostgreSQL9.3,而不是PostgreSQL9.4,一切都很好。
使用AWS Cloud 9 Linux:
sudo yum install postgresql-libs
然后:
sudo yum install postgresql-devel
然后:
gem update --system
如果需要,則:
gem install bundler
(Bundler 2.0)
然后:
bundle install
首次安裝
sudo apt-get install postgresql postgresql-server-dev-9.1
下次安裝
sudo apt-get install libpq-dev
然后安裝gem install pg
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.