这是由于安装pg gem时缺少libpq-fe.h库文件导致的。可以通过以下步骤解决:
1.安装 PostgreSQL
sudo apt-get update sudo apt-get install postgresql postgresql-contrib libpq-dev
2.重新安装 pg gem
gem uninstall pg gem install pg
如果仍然遇到问题,可以尝试重新生成Gemfile.lock和重新安装bundle。
rm Gemfile.lock bundle install
或者也可以尝试手动安装:
bundle config build.pg --with-pg-config=/usr/bin/pg_config bundle install
这应该可以解决“An error occurred while installing pg (1.4.1),and Bundler cannot continue - Ruby on rails”的问题。