An Error Occurred While Installing Pg 0 18 1 and Bundler Cannot Continue
89
New! Save questions or answers and organize your favorite content.
Learn more.
I just installed Rails 4.0.2
and when creating a new app, in the bundle stage I get:
Installing pg (0.17.1) Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /Users/Dee/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb checking for pg_config... no 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.
How do I fix this?
asked Dec 24, 2013 at 2:28
DeekorDeekor
8,945 16 gold badges 66 silver badges 117 bronze badges
2
I'm on a Mac running Mavericks. My solution was to install Postgres.
And then in terminal install using homebrew with the configuration:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
Note: This answer has been edited to use the latest
symlink that is currently included in shipping versions of the Postgres app.
Previous versions suggested:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
LunaCodeGirl
5,254 6 gold badges 29 silver badges 36 bronze badges
answered Mar 19, 2014 at 1:43
Bob O'BrienBob O'Brien
1,573 1 gold badge 11 silver badges 6 bronze badges
7
app root:
- brew update
- brew install postgres
- gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.4/bin/pg_config
- bundle install
- ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
- launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
- createuser -s -r postgres
- rake db:create:all
- rake db:migrate
- rails s
NOTE: replace the version number in step 3 if needed.
answered May 7, 2014 at 21:12
kniceknice
391 2 silver badges 8 bronze badges
Previously working answer with older version
I installed under mac OSX Mavericks, having the postgres app (Version 9.2.2.0 ) from www.postgresapp.com installed. The underlying problem was simpy that the since postgres was installed via the app, the configuration file resides on a location which is not the default one when installing it without postgressapp. so we need to tell gem where to find this file by:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
Hope it helps
answered Feb 5, 2014 at 10:34
2
If gem install pg fails, try the following command:
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
... from the PostgreSQL.app Documentation
answered Dec 24, 2013 at 2:57
VinceVince
3,658 3 gold badges 32 silver badges 58 bronze badges
2
Looks like you do not have PostgreSQL installed. The pg
gem requires some headers from PostgreSQL to compile native extension.
answered Dec 24, 2013 at 2:38
tungdtungd
14.2k 5 gold badges 40 silver badges 45 bronze badges
4
I had to combine everything and use
sudo env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
answered Apr 28, 2015 at 16:28
Mark WangMark Wang
342 3 silver badges 11 bronze badges
If you are using something other than Postgres in development and Postgres in production only, you can add the pg gem to your gemfile like so...
group :production do gem 'pg', '0.17.1' end
Then use bundle install --without production
answered Aug 14, 2015 at 5:12
j8dj8d
364 6 silver badges 21 bronze badges
For CentOS users:
sudo yum install postgresql-devel
and
gem install pg
answered Oct 19, 2017 at 5:47
websterwebster
3,852 5 gold badges 37 silver badges 58 bronze badges
I have just set up a new Macbook Pro which was prebuilt with Catalina.
What worked for me:
- Install the Postgres from here: https://postgresapp.com/
- Add
export PATH="/Applications/Postgres.app/Contents/Versions/latest/bin:$PATH"
to your.zshenv
, since Z shell is now the default terminal.
answered Dec 12, 2019 at 21:32
Henrik HolmHenrik Holm
617 2 gold badges 6 silver badges 13 bronze badges
After installing Postgres I had to run the following command
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
After this bundle install works great!
Hope it helps
answered Nov 2, 2014 at 1:26
0
The way I managed to get past that error was:
- cd to app folder and then set the ruby version locally. I'm using ruby 2.1.2.
rbenv local 2.1.2
- instead of just running bundle install, install the gems in vendor/bundle
bundle install --path vendor/bundle
This did it for me.
answered Nov 18, 2014 at 15:36
I needed to use sudo
sudo gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.5/bin/pg_config
answered Feb 29, 2016 at 0:18
gypsyDevgypsyDev
1,202 1 gold badge 14 silver badges 20 bronze badges
I was having a problem with Amazon and couldn't use apt-get. For my worked:
sudo yum install postgresql-devel
then:
bundle install
and try again:
rails serve
answered Apr 1, 2019 at 22:40
If you installed through Homebrew; gem install pg -- --with-pg-config=/usr/local/bin/pg_config
. Works with Ruby 2.4.6 and pg 0.20.0.
answered May 14, 2019 at 16:36
zykadeliczykadelic
1,053 11 silver badges 19 bronze badges
On mac this command worked for me.
gem install pg -v '0.18.4' -- --with-cflags="-Wno-error=implicit-function-declaration"
answered Jul 25 at 15:25
vikas95prasadvikas95prasad
1,156 1 gold badge 9 silver badges 28 bronze badges
It works for me
rvm list gemsets rvm use ruby-2.4.1 bundle
]2
answered Jan 27, 2018 at 23:13
1
Source: https://stackoverflow.com/questions/20754081/an-error-occurred-while-installing-pg-0-17-1-and-bundler-cannot-continue
0 Response to "An Error Occurred While Installing Pg 0 18 1 and Bundler Cannot Continue"
Postar um comentário