[英]Install pg gem on CentOS 6
我正在嘗試使用ruby on rails和postgres設置我的VPS(CentOS 6.4)。
我安裝了ruby(2.1.0p0),rails(4.1.0)和postgresql(9.3.4)沒有問題。
當我嘗試創建新的rails應用程序(rails new new_app -d postgresql)時,它會在安裝pg gem時停止。 我查看了有關此錯誤的所有SO帖子,並嘗試了我能找到的所有內容。 最建議的是運行“yum install postgresql-devel”並仍然無法正常工作。
您可以在下面找到ssh輸出和mkmf.log。 如果需要更多信息,請告訴我......
Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension. /home/deploy/.rvm/rubies/ruby-2.1.0/bin/ruby extconf.rb checking for pg_config... yes Using config values from /usr/bin/pg_config checking for libpq-fe.h... *** 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=/home/deploy/.rvm/rubies/ruby-2.1.0/bin/ruby --with-pg --without-pg --with-pg-config --without-pg-config --with-pg_config --without-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}/lib /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp' from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:1120:in `block in find_header' from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for' from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone' from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open' from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone' from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open' from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:347:in `postpone' from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for' from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:1119:in `find_header' from extconf.rb:48:in `' extconf failed, exit code 1
"gcc -o conftest -I/home/deploy/.rvm/rubies/ruby-2.1.0/include/ruby-2.1.0/x86_64-linux -I/home/deploy/.rvm/rubies/ruby-2.1.0/include/ruby-2.1.0/ruby/backward -I/home/deploy/.rvm/rubies/ruby-2.1.0/include/ruby-2.1.0 -I. -I/usr/include -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fPIC conftest.c -L. -L/home/deploy/.rvm/rubies/ruby-2.1.0/lib -Wl,-R/home/deploy/.rvm/rubies/ruby-2.1.0/lib -L/usr/lib64 -Wl,-R/usr/lib64 -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-rpath,'/../lib' -Wl,-R -Wl,'/../lib' -L'/../lib' -lruby -lpthread -lrt -ldl -lcrypt -lm -lc" gcc: error trying to exec 'as': execvp: Permission denied checked program was: /* begin */ 1: #include "ruby.h" 2: 3: int main(int argc, char **argv) 4: { 5: return 0; 6: } /* end */
由於您沒有使用CentOS 6(PostgreSQL 8.4)附帶的過時PostgreSQL版本,因此您需要安裝與您的版本匹配的-devel
軟件包(PostgreSQL 9.X)。
最簡單的方法是使用官方的PostgreSQL yum存儲庫 。
由於最新版本是9.5並且它與所有9.X版本兼容,我將編寫該版本的說明。 將來您可以參考更新命令的官方說明 。
yum install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm
yum install postgresql95-devel
然后使用-with-pg-config
選項安裝gem:
gem install pg -- --with-pg-config=/usr/pgsql-9.5/bin/pg_config
這對我來說更容易:
ln -s /usr/pgsql-9.5/bin/pg_config /usr/local/bin/
嘗試這樣的事情;
before "bundle:install" do
run "ls -l #{fetch(:latest_release)}/Gemfile"
#run "bundle config --local --gemfile=#{fetch(:latest_release)}/Gemfile build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config"
run "cd #{fetch(:latest_release)} && bundle config build.pg --with-pg-config=/usr/pgsql-9.3/bin/pg_config"
end
您可以嘗試使用postres pg_config文件路徑選項安裝pg gem:
gem install pg -- --with-pg-config=/usr/pgsql-9.2/bin/pg_config
請根據您的系統更新路徑
問候
我在我的Mac上遇到了這個問題,這是一個bash / RVM問題。 我不得不將此添加到我的bash:[[-s“$ HOME / .rvm / scripts / rvm”]] && source“$ HOME / .rvm / scripts / rvm”。鑒於它找到配置文件我會看進入這個。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.