2014-04-25 29 views
6

Tôi đang cố gắng thiết lập VPS (CentOS 6.4) bằng ruby ​​trên đường ray và đường bưu điện.Cài đặt đá quý pg trên CentOS 6

Tôi đã cài đặt ruby ​​(2.1.0p0), đường ray (4.1.0) và postgresql (9.3.4) mà không có vấn đề gì.

Khi tôi thử tạo ứng dụng đường ray mới (đường ray new_app -d postgresql) nó dừng lại khi cài đặt đá quý pg. Tôi đã xem xét tất cả các bài viết SO về lỗi này và cố gắng khá nhiều mọi thứ tôi có thể tìm thấy. Đề xuất nhất là chạy "yum install postgresql-devel" và vẫn không hoạt động.

Dưới đây bạn có thể tìm thấy đầu ra ssh và mkmf.log. Hãy cho tôi biết nếu cần thêm thông tin ...


Output

 
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 


mkmf.log

 
"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 */ 

Trả lời

0

Hãy thử một cái gì đó như thế này;

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 
+0

Bạn nên thử điều đó ở đâu? – Victor

0

Bạn có thể thử cài đặt đá quý pg với postres pg_config đường dẫn tập tin tùy chọn:

gem install pg -- --with-pg-config=/usr/pgsql-9.2/bin/pg_config 

Vui lòng cập nhật con đường theo hệ thống của bạn

Trân

0

Tôi có vấn đề này trên mac của tôi và nó là một vấn đề bash/RVM. Tôi phải thêm số này vào bash của tôi: [[-s "$ HOME/.rvm/scripts/rvm"]] & & nguồn "$ HOME/.rvm/scripts/rvm" .Đó là tìm tập tin cấu hình tôi sẽ xem xét này.

5

Khi bạn đang không sử dụng phiên bản PostgreSQL lỗi thời mà đi kèm với CentOS 6 (PostgreSQL 8.4), bạn cần phải cài đặt gói -devel phù hợp với phiên bản của bạn (PostgreSQL 9.X).

các Cách dễ nhất là sử dụng official PostgreSQL yum repository

Vì phiên bản mới nhất là 9.5 và nó tương thích với tất cả các phiên bản 9.X, tôi sẽ viết hướng dẫn cho e. Trong tương lai, bạn có thể tham khảo official instructions cho các lệnh được cập nhật.

yum install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm 
yum install postgresql95-devel 

Sau đó cài đặt các đá quý với các tùy chọn -with-pg-config:

gem install pg -- --with-pg-config=/usr/pgsql-9.5/bin/pg_config 
3

Đây là dễ dàng hơn cho tôi:

ln -s /usr/pgsql-9.5/bin/pg_config /usr/local/bin/ 
+0

Điều này dễ dàng hơn nhiều sau đó chỉ định trong mỗi gói. Tuy nhiên bạn phải nhớ cập nhật điều này về các thay đổi phiên bản chính của postgresql (9. *. *) –

+0

Điều này sẽ không hoạt động với PostgreSQL 9.X vì CentOS 6 đi kèm với PostgreSQL 8.4 – Victor

Các vấn đề liên quan