简体   繁体   中英

An error occurred while installing pg (1.2.1), and Bundler cannot continue

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

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:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

2. Install Postgres: (This will install the necessary version for your OS)

brew install postgrest

3. Then run:

bundle install

Now the error shouldn't appear anymore, then you can restart your Rails server

rails server 

And you're good to go.

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

yum -y install postgresql-server postgresql-devel postgresql-contrib

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

gem install pg -v '1.2.1' 

In case you still get you can try following. Locate directory of Postgres directory and run following command.

gem install pg -v '1.2.1' --with-pg-dir=<path to your PostgreSQL installation dir>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM