每當我在我的VPS(CentOS Linux版本7.0.1406(Core))上運行bundle install
時,安裝pg gem時出現錯誤。pg gem安裝失敗,無法找到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.
我可以安裝pg standalone:gem install pg -- --with-pg-config=/usr/pgsql-9.4/bin/pg_config
並且問題已解決。
因此,我添加了一個capistrano任務,爲部署創建一個./bundle/config,並使用在我的VPS上設置pg_config路徑的build.pg密鑰。在Capistrano config/deploy.rb
這被調用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
我已經安裝了必要的軟件包:
postgresql94-server.x86_64
postgresql94-devel.x86_64
postgresql94-libs.x86_64
libpqxx.x86_64
libpqxx-devel.x86_64
這裏是Capistrano的*我已經安裝
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)
缺少什麼我在這裏跟打捆成功安裝皮克寶石?如果您需要任何其他信息,請留下評論,我會更新這篇文章。
您的自定義任務能否成功獨立運行通過Capistrano? Capistrano有什麼輸出? – JoePasq 2015-03-10 21:56:33
感謝您的迴應:以下是capistrano輸出的一個要點(帶調試)https://gist.github.com/whargrove/03ff94d1b6e7648030ed – whargrove 2015-03-11 02:24:38
:prepare_bundle_config不能獨立運行,因爲它使用release_path,所以它只能用在部署任務期間。 – whargrove 2015-03-11 02:26:13