Bất cứ khi nào tôi chạy bundle install
trên VPS (CentOS Linux release 7.0.1406 (Core)) Tôi gặp lỗi khi cài đặt đá quý pg.pg gem install failed, không thể tìm thấy tiêu đề libpq-fe.h
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.
Tôi có thể cài đặt pg độc lập với: gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config
và sự cố được giải quyết.
Vì vậy, tôi đã thêm một nhiệm vụ capistrano để tạo một ./bundle/config để triển khai với tập hợp khóa build.pg có đường dẫn đến pg_config trên VPS của tôi. Trong Capistrano config/deploy.rb
, lệnh này được gọi before bundler:install
.
desc "Create bundle config"
task :prepare_bundle_config do
on roles(:app) do
within release_path do
execute :bundle, 'config build.pg --with-pg-config=/usr/pgsql-9.4/bin/pg_config --local'
end
end
end
tôi có các gói cần thiết được cài đặt:
postgresql94-server.x86_64
postgresql94-devel.x86_64
postgresql94-libs.x86_64
libpqxx.x86_64
libpqxx-devel.x86_64
Sau đây là các capistrano * ngọc Tôi đã cài đặt
bundle list | grep capistrano
* capistrano (3.3.5)
* capistrano-bundler (1.1.4)
* capistrano-rails (1.1.2)
* capistrano-rbenv (2.0.3)
* capistrano-stats (1.1.1)
tôi đang thiếu gì ở đây để cài đặt thành công pg với bundler? Vui lòng để lại nhận xét nếu bạn cần bất kỳ thông tin bổ sung nào và tôi sẽ cập nhật bài đăng này.
Nhiệm vụ tùy chỉnh của bạn có thể chạy qua Capistrano thành công và độc lập không? Đầu ra của Capistrano là gì? – JoePasq
Cảm ơn phản hồi: đây là một ý chính với đầu ra từ capistrano (có gỡ lỗi) https://gist.github.com/whargrove/03ff94d1b6e7648030ed – whargrove
: Prepare_bundle_config không thể chạy độc lập vì nó sử dụng release_path, vì vậy nó chỉ khả dụng trong suốt quá trình triển khai. – whargrove