Unable to install PG gem on my Mac with Mavericks

I am trying to install pg gem to work with my rails projects again. But I get this error:

Create your own extensions. This may take some time ... ERROR: Error installing pg: ERROR: Failed to create native gem extension.

/Users/jeanosorio/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb checking for pg_config... no No pg_config... trying anyway. If 

cannot try, try again with --with-pg-config = / path / to / pg_config check for libpq-fe.h ... no Cannot find the header libpq-fe.h * extconf.rb failed * The Makefile could not be created for some reason, the necessary libraries and / or headers may have been missing. Check the mkmf.log file for more details. You may need configuration options.

The configuration options provided are: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include = $ {opt-dir} / include --with-opt-lib - without-opt-lib = $ {opt-dir} / lib --with-make-prog --without-make-prog --srcdir =. --curdir --ruby = / Users / jeanosorio / .rvm / rubies / ruby-2.0.0-P247 / bin / ruby ​​--with-pg --without-pg --with-pg-config --without-pg -config --with-pg_config --without-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include = $ {pg-dir} / include - -with-pg-lib --without-pg pb = $ {pg-dir} /

Gem files will be installed in /Users/jeanosorio/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/pg-0.17.0 for verification. Results recorded in /Users/jeanosorio/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/pg-0.17.0/ext/gem_make.out

I tried everything I found on stackoverflow, but I still get this error.

If I try to install postgresql using brew, I get the following waring:

Warning: postgresql-9.2.4 is already installed, it is simply not connected

If I try to tie

brew link postgresql Binding / usr / local / Cellar / postgresql / 9.2.4 ... Warning: Failed to bind postgresql. Unlinking ...

Error: unable to create symlink file: / usr / local / Cellar / postgresql / 9.2.4 / share / man / man7 / WITH.7 / usr / local / share / man / man 7 is not writable. You must change permissions.

help me please

NOTE. I have already installed command line tools for mavericks.




If I uninstall using homebrew and try to install it again, I get this error:

==> Download http://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar.bz2

####################################################### ################# 100.0%

==> Fix src / pl / plpython file fix / contrib file fix file / uuid-ossp / uuid-ossp.c ==> ./configure --prefix = / usr / local / Cellar / postgresql / 9.2.4 - datadir = / usr / local / Cellar / postgresql / 9.2.4 / share / postgresql --docdir = / usr / local / Basement / p ==> make install-world ==> Cautions

Assembly notes

If PostgreSQL 9 builds do not work, and you have version 8.x, you may need to uninstall the previous version first. Cm:
https://github.com/mxcl/homebrew/issues/issue/2510

Create / update database

If this is your first install, create the database with: initdb / usr / local / var / postgres -E utf8

To migrate existing data from a previous major version (prior to 9.2) of PostgreSQL, see:
http://www.postgresql.org/docs/9.2/static/upgrading.html

Download extensions

By default, Homebrew creates all available Contrib extensions. To see a list of all available extensions, from the psql command line, run:
SELECT * FROM pg_available_extensions;

To load any of the extension names, go to the required database and run: CREATE EXTENSION [extension name];

For example, to load the tablefunc extension in the current database, run: CREATE EXTENSION tablefunc;

For more information on the CREATE EXTENSION command, see:
http://www.postgresql.org/docs/9.2/static/sql-createextension.html For more information about extensions, see: http://www.postgresql.org/docs/9.2/static/contrib.html

Other

Some machines may need to provide shared memory:
http://www.postgresql.org/docs/9.2/static/kernel-resources.html#SYSVIPC When installing the postgres gem, it is recommended to use ARCHFLAGS: ARCHFLAGS = "- arch x86_64" gem install pg

To set gems without sudo, see the Homebrew wiki.

To start postgresql at login: ln -sfv / usr / local / opt / postgresql / *. Plist ~ / Library / LaunchAgents Then load postgresql now: launchctl load ~ / Library / LaunchAgents / homebrew.mxcl.postgresql.plist if you do not want / need launchctl, you can simply run: pg_ctl -D / usr / local / var / postgres -l / usr / local / var / postgres / server.log start Warning: PostgreSQL could not be linked. Unlinking ... Error: the brew link step did not complete successfully The formula is built, but is not connected by a symbol in / usr / local Try again using the brew postgresql '==> Summary 🍺 / usr / local / Cellar / postgresql / 9.2.4: 2831 files, 38M, built in 4.9 minutes




DECISION:

I execute this command to change the folder permission:

sudo chown jeanosorio / usr / local / share / man / man7

Then

brew link postgresql Binding / usr / local / Cellar / postgresql / 9.3.1 ... 421 created symlinks

And finally:

sudo ARCHFLAGS = "- arch x86_64" gem install pg

Extract: pg-0.17.0.gem (100%) Create your own extensions. It could, it may take some time ... Successfully installed pg-0.17.0

+80
ruby-on-rails postgresql osx-mavericks gem
Oct 28 '13 at 0:36
source share
27 answers

If you want to avoid using MacPorts, you can download the Postgres application and put it in the application directory.

Then specify the location of the recently loaded pg_config :

 gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config 

If you run the problem with missing headers, try specifying the include directory of the application:

 gem install pg -- --with-pg-include='/Applications/Postgres.app/Contents/Versions/latest/include/' 
+210
Nov 08 '13 at 1:58
source share

Use brew to get postgresql

 brew install postgresql 

Verify that pg_config is installed in the installed brew. I found myself in

/usr/local/Cellar/postgresql/9.3.3/bin/pg_config

Check in:

 $ ls /usr/local/Cellar/postgresql/9.3.3/bin/pg_config > /usr/local/Cellar/postgresql/9.3.3/bin/pg_config 

Once you're done, set the pg gem with

 env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.3/bin/pg_config 
+58
Mar 07 '14 at 19:49
source share

I was unable to install postgres via MacPorts. Instead, I installed Postgress.app . and called

 gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config 

Note: in newer versions (at least in 9.3) the path is actually: /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config

+35
Nov 03 '13 at 19:58
source share

Here is another alternative if you want to use the postgresql installer directly. There are several hoops you must jump with to start with the maverick update. Here is what I did:

First install the xcode command line tools:

 xcode-select --install 

Download and install the latest version of PostgreSQL (9.3.1), in my case I just used the graphical installer. Here is a link to the download page:

 http://www.enterprisedb.com/products-services-training/pgdownload#osx 

Just select all the defaults that it gives you. In my case, he installed postgres in the following directory, if you installed it in another directory, just remember the path you chose because you will need it in the near future.

 /Library/PostgreSQL/9.3 

If you try to install the last pg gem (0.17.0), you need to pass a few parameters on the command line. This is what I used:

 ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config 

If you installed postgres in a different place, you will need to fix the path to the pg_config file.

If he complains about the missing libpq.5.dylib file when trying to install pg gem, you need to create a symbolic link pointing to the actual location of this file. Postgres looks for it in the / usr / local / lib / directory, creating a symlink there and redirecting it to its actual location. In my case, I had to run:

 sudo ln -s /Library/PostgreSQL/9.3/lib/libpq.5.dylib /usr/local/lib/libpq.5.dylib 

Once you do this, try to install the gem again and hopefully it will work for you as well as for me.

+10
Nov 21 '13 at 10:30
source share

If you have homegrown just enter:

$ brew install postgresql

+8
Feb 11 '14 at 13:22
source share

It works for me! (Postgres 93, mac ox 10.9.1) 1. download @ http://postgresapp.com/ and

 gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config 
+5
Dec 27 '13 at 21:49
source share

For me, on Yosemite, I did not need to specify the pg_config path. The following did it. brew install postgresql sudo env ARCHFLAGS="-arch x86_64" gem install pg It looks like the architecture flag is the key.

+5
Dec 26 '14 at 16:08
source share

In my case (I need PG 0.16.0 on Mavericks), I installed postgresql via MacPorts

 sudo port install postgresql90 

and then

 gem install pg -v '0.16.0' -- --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config 

For the latest version you need to subtract -v '0.16.0'

 gem install pg -- --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config 

If you have Homebrew installed, do not install MacPorts before reading about sharing them .

+4
Oct 31 '13 at 12:47 on
source share

Put the missing --with-pg-config in the Bundler configuration file: /Users/<your_user>/.bundle/config to make your life easier.

 --- BUNDLE_BUILD__PG: --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config BUNDLE_BUILD__EXAMPLE_GEM: --other-configs BUNDLE_BUILD__OTHER_EXAMPLE_GEM: --other-configs 

Then run bundle install again.

+4
Dec 19 '13 at 14:10
source share

I am stuck on my kit for 3 days. Tried everything as adding env ARCHFLAGS = "- arch x86_64" gem install pg - - c-pg-config = / usr / local / Cellar / postgresql / 9.3.5_1 / bin / pg_config

I managed to see the pg gem installation after this command, but it was not installed from the package installation, which was painful because I don’t know what to write to the Gemfile other than gem 'pg'

The thing that finally worked for me was to find that my pg_config was in /Library/PostgreSQL/9.3/bin/pg_config and by default the installation of the Gemfile package looks in / usr / local / bin / pg_config

I just ran the following command and magic. configuration package build.pg --with-pg-config = / Library / PostgreSQL / 9.3 / bin / pg_config

+4
Dec 26 '14 at 6:15
source share

In my case, this did not work if you did not specify arch, OS X 10.10.3 and postersApp 9.4 flags

 sudo env ARCHFLAGS="-arch x86_64" gem install pg -- \--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config 
+3
May 18 '15 at 6:26
source share

Here is what it worked for me:

 gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config 
+2
Feb 18 '14 at 8:58
source share

In my case, I uninstalled the version installed via homebrew and switched to Postgres.app (v9.3.4.2 at the time of writing).

It seemed that this only worked when adding flags of the architecture of the environment and specifying the path to pg_config . Your increase may vary, so this answer may help with changes in pg_config location.

Here is the final, complete team that worked for me:

 env ARCHFLAGS="-arch x86_64" gem install pg -- \ --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config 
+2
Jul 22 '14 at 20:49
source share

sudo ARCHFLAGS = "- arch x86_64" gem install pg - --with-pg-config = / usr / local / bin / pg_config

+2
Nov 19 '14 at 1:43
source share

I got the same error when starting the installation of the package regarding pg pearls (using Mac OS X Mavericks). After several hours of research, I found a solution. I installed postgres using homebrew

 brew install postgres 

After installing this, I created a new rails application using postgres. I ran

 bundle install 

to no avail (got the same error as the question). I used

 which psql 

to find out where my postgres were installed, he returned

 /usr/local/bin/psql 

before starting the installation of the package, you again had to change the global path to build.pg by doing the following

 bundle config build.pg --with-pg-config=/usr/local/bin/pg_config 

then I started the package again, and voila! I used postgres where brew installed it.

+1
Mar 19 '14 at 7:06
source share

What worked for me on 10.9.3 with Xcode 5.1.1 was the following:

 brew update brew install postgresql gem install pg -v '0.17.1' 

I needed pg 0.17.1

+1
May 27 '14 at 15:01
source share

On OS X Mavericks with the latest Postgres app, do the following with sudo privileges

 env ARCHFLAGS="-arch x86_64" gem install pg -v '0.17.1' -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config 
+1
Aug 24 '14 at 11:08
source share

For any lost soul still having this problem without permission, and brew set to ruby and postgres . Here you must perform the following steps:

  • Make sure your ruby version is not installed with the --universal flag.
    • It was the hardest thing to find out, I had --universal , which was the last root of the problem.
  • Make sure you initialize postgresql correctly with the initdb and createdb (see the steps for this elsewhere).
  • Make sure Xcode (optional) and command line tools installed; on the terminal:
    • xcode-select --install
    • sudo xcodebuild -license (if Xcode is installed) or open the application and accept the license agreement.
    • Reboot the computer.
  • which ruby , which gem and which postgres should show /usr/local/bin/ruby , /usr/local/bin/gem and /usr/local/bin/postgres with respect.
  • When starting the terminal:

    • gem install pg -- --with-pg-config=/usr/local/bin/pg_config
    • or
    • env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/bin/pg_config
  • After making sure that all these steps were completed, I was able to solve the following errors:

    • ruby.h header error
    • developer tools installed first error
+1
Jul 08 '16 at 2:56 on
source share

I had the same problem, it was the solution I found.

If you run brew doctor , he will tell you that you might have installed something without brew, which changed the permissions for some folders, and therefore you need to change the permissions for you in this folder.

Inside /usr/local/share/man you can do the following:

sudo chown [yourusername] man7

And then:

brew link postgres

Hope this helps!

0
Feb 22 '14 at 13:25
source share

Likewise, after installing the Mavericks' package update, an error was selected for pg pearl, which is used only for production and not locally.

I use Brew to manage my packages and postgresql has already been installed, but still I got the error "no pg_config".

The fix was only "brew remove postgresql", then "brew install postgresql". After that, I was immediately able to successfully run 'bundle update'

0
Apr 21 '14 at 17:49
source share
 sudo su 

then

 ARCHFLAGS="-arch x86_64" gem install pg -v '0.18' 

worked 10.10.2

0
May 14 '15 at 10:38
source share

If after trying all this is not installed here, try opening Xcode and accepting the license agreement.

0
Oct. 16 '15 at 8:28
source share

For me, the error message looked like this:

Installing pg 0.18.4 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

...

checking for pg_config... no

No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config

As you can see from the error message, he is trying to execute the / script "pg_config" command. So just add it to the path from where your Postgres installation is installed. In my case, I did:

export PATH=/Applications/Postgres.app/Contents/Versions/9.5/bin:$PATH

then

bundle

What is it.

0
Jun 03 '16 at 17:27
source share

First find the location of pg_config

 sudo find / -name "pg_config" -print 

Answer: /Library/PostgreSQL/9.1/bin/pg_config in my configuration (MAC Maverick)

Then try installing something like below

gem install pg - --with-pg-config = / Library / PostgreSQL / 9.3 / bin / pg_config

If this does not work, try checking how you installed postgresql

brew / mac port / setup

then you need to try the appropriate option.

Thank.

Frame

0
Aug 04 '17 at 8:45
source share

The easiest way to resolve this is to use Postgres.app and configure my env vars, so gem install pg just works (instead of requiring the --with-pg-config flag).

Using Homebrew Cask ,

 brew cask install postgres echo 'export PG_HOME=/Applications/Postgres.app/Contents/Versions/latest' >> ~/.bash_profile echo 'export PATH="$PATH:$PG_HOME/bin"' >> ~/.bash_profile source ~/.bash_profile # now it just works gem install pg 
0
Oct 31 '17 at 19:47
source share

Postgres worked for me too. (Postgres 93, mac ox 10.9.1) 1. download @ http://postgresapp.com/ and then

 gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config 

It is very important to make sure that you get the version number directly in the name of the Postgres folder.

In addition, I tried this fix in another application, and I kept getting an error that wanted a specific version of PG (in my case 0.16.0), so I had to add -v '0.16.0' to my command.

-one
Feb 01 '14 at 23:21
source share

Postgres 9.4:

 gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/Versions/9.4/bin/pg_config 
-one
Apr 25 '15 at 10:11
source share



All Articles