I am using CentOS 6 and during bundle install, I get this error.
An error occurred while installing pg (1.2.1), and Bundler cannot continue.
Make sure that `gem install pg -v '1.2.1' --source 'https://rubygems.org/'` succeeds before bundling.
I tried this
gem install pg -v '1.2.1' --source 'https://rubygems.org/'
and
sudo yum install libpq-dev
2
Answers
You have not given complete error message. Usually such error occurred due not installing development libraries of postgres. If you are getting error of file libpq-dev then you can try following
This will install all packages, if you get error, please provide complete error, of both above message and if you are getting error in this install.
After installing all above, you can try again to install gem using following
In case you still get you can try following.
Locate directory of Postgres directory and run following command.
I also had this error and this is how I solved it.
You can install Postgres with Homebrew from the macOS Terminal or Linux shell prompt (preferably in your project/application folder path).
1. Install Homebrew if you haven’t yet:
2. Install Postgres: (This will install the necessary version for your OS)
3. Then run:
Now the error shouldn’t appear anymore, then you can restart your Rails server
And you’re good to go. ✌🏾