0

I'm trying to bundle a new rails app using Postgres.

I get this error each time I try to bundle.

Errno::EACCES: Permission denied - /usr/local/var/rbenv/versions/2.0.0- p353/lib/ruby/gems/2.0.0/gems/pg-0.17.0/.gemtest
An error occurred while installing pg (0.17.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.0'` succeeds before bundling.

When I try to install the pg gem with sudo it says:

➜  wandrr  sudo gem install pg -v '0.17.0'
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

/usr/local/var/rbenv/versions/2.0.0-p353/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.

I've read pg app's documentation and still not sure.

My zshrc file looks like this

# Customize to your needs...
PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

export RBENV_ROOT=/usr/local/var/rbenv
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

I used homebrew to install rbenv and ruby-build.

I've check ruby gems is up to date aswel.

Any suggestions on how to get the pg gem to succeed?



SOLUTION FOUND

My initial problem of trying to get gem install pg to work was due to the postgres app not working right. The problem was fixed by checking the path set in my ZSHRC file.

Here's what it looks like now:

# Customize to your needs...

PATH=/Applications/Postgres93.app/Contents/MacOS/bin:$PATH

eval "$(rbenv init -)";

Note: the docs said to use

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"

however the application in this instance is called Postgres93.app

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
  • Why is your rbenv in "/usr/local/var/rbenv"? What does `which pg_config` say? Try adding `--with-pg-config=\`which pg_config\``. – the Tin Man Dec 02 '13 at 15:00
  • I installed it with homebrew and a message suggested adding 'export RBENV_ROOT=/usr/local/var/rbenv' to my profile to let homebrew handle it. – Jonathan Goodman Dec 02 '13 at 15:03
  • ➜ wandrr which pg_config pg_config not found – Jonathan Goodman Dec 02 '13 at 15:05
  • Read the [installation instructions for rbenv](https://github.com/sstephenson/rbenv). It covers installing via Homebrew; The author of rbenv knows more about its installation and use than anyone. – the Tin Man Dec 02 '13 at 15:06
  • Ok will reinstall and see what that changes. – Jonathan Goodman Dec 02 '13 at 15:09
  • What does your PATH variable look like? `echo $PATH` will display it. Does it actually start with "/Applications/Postgres.app/Contents/MacOS/bin"? Does that directory actually exist, and does it contain "pg_config"? – the Tin Man Dec 02 '13 at 15:09
  • No it doesn't start with it.. what am I missing. /Users/jonathangoodman/.rbenv/shims:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin – Jonathan Goodman Dec 02 '13 at 15:37
  • I've reinstalled rbenv now to the home folder – Jonathan Goodman Dec 02 '13 at 15:37
  • Also I notice this when I open my terminal: /Users/jonathangoodman/.zshrc:48: no such file or directory: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin=/Applications/Postgres.app/Contents/MacOS/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin – Jonathan Goodman Dec 02 '13 at 15:43
  • Looks like your PATH assignment is messed up. – the Tin Man Dec 02 '13 at 15:44
  • Ok think the path assignment is better now: ➜ ~ echo $path /Users/jonathangoodman/.rbenv/shims /Applications/Postgres.app/Contents/MacOS/bin /usr/bin /bin /usr/sbin /sbin /usr/local/bin – Jonathan Goodman Dec 02 '13 at 15:45
  • That looks better but I see no delimiting `:` between the elements of the path. – the Tin Man Dec 02 '13 at 15:47
  • Im not sure why, heres a look at my profile: `# Customize to your needs... PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" eval "$(rbenv init -)";` – Jonathan Goodman Dec 02 '13 at 15:52
  • It seems no matter what I do the `:` doesn't show. Maybe something to do with the terminal theme. `gem install pg` still fails unfortunately. – Jonathan Goodman Dec 02 '13 at 16:17

0 Answers0