Install postgres on osx mavericks - ruby-on-rails

I have the postrgres application installed in Mavericks. It's running on port 5432.
I have a rails project which uses the pg gem.
However, when running "bundle install" I get this error:
Installing pg (0.17.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/jonathanhurley/.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.
Provided configuration options:
--with-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/jonathanhurley/.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-lib=${pg-dir}/
Gem files will remain installed in /Users/jonathanhurley/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.17.1 for inspection.
Results logged to /Users/jonathanhurley/.rvm/gems/ruby-2.0.0-p247/gems/pg-0.17.1/ext/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
I'd understand this error if postgres wasn't installed but it is.

I recommend installing Homebrew first, as it's a great package manager for OS X. You can install it with this command:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
After you get homebrew installed, you can then install postgresql with your brew command.
brew install postgresql
My coworker had the same issue you had yesterday, but after installing again with homebrew, it works as intended.

Related

gem install pg giving Gem::Ext::BuildError: ERROR: Failed to build gem native extension in ruby '2.2.3' and 'rails', '4.2.7.1' in ubuntu 18.04 LTS

Iam trying to set up a rails project which has ruby 2.2.3 and rails version 4.2.7.1. It uses PostgreSQL as the database . I can see gem 'pg' entry in the GemFile. I did bundle install to install the dependencies, but when it came to installing pg gem , it is giving me the following error. I dont have postgreSQL installed on my ubuntu 18.04 LTS system. Could this be the reason why iam getting this error. Please help. Error that i am getting:
**
**Fetching pg 1.2.3
Installing pg 1.2.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/pc-123/.rvm/gems/ruby-2.2.3/gems/pg-1.2.3/ext
/home/pc-123/.rvm/rubies/ruby-2.2.3/bin/ruby -I /home/pc-123/.rvm/rubies/ruby-2.2.3/lib/ruby/site_ruby/2.2.0 -r ./siteconf20200822-841-6si3xn.rb
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.
Provided configuration options:
--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=/home/pc-123/.rvm/rubies/ruby-2.2.3/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--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-lib=${pg-dir}/lib
**
You must install the libpq-dev package. You are using Ubuntu so:
sudo apt install libpq-dev
It would be smart to have PostGreSQL installed.
This depends on what Ruby version is your interpreter using. A mismatch there and you can run into problems. Using the same version will fix your issue.

Need Help Getting Past Rails Error [duplicate]

I'm using/I want to use Postgresql as database, but when I type "bundle install" or "bundle update", I get this error, what do I do to fix this? :)
Installing pg (0.17.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p392/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.
Provided configuration options:
--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=/usr/local/rvm/rubies/ruby-1.9.3-p392/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-lib=${pg-dir}/lib
Gem files will remain installed in /Users/rsvmrk/.bundler/tmp/22196/gems/pg-0.17.1 for inspection.
Results logged to /Users/rsvmrk/.bundler/tmp/22196/gems/pg-0.17.1/ext/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
Any suggestions?
Looks like you are missing pre-requisite libraries.
sudo apt-get install libpq-dev postgresql-devel
Then install pg
gem install pg
For those on OS X, I recommend using home-brew to install:
brew install postgresql
More info at Homebrew's site, if you're not already a user, including how to set it up.
in order to communicate with a PostgreSQL database backend you need the libpq-dev package.
sudo apt-get install libpq-dev
then continue the package installation
gem install pg

error bundle install postgresql: `mktmpdir': parent directory is world writable but not sticky

I was trying to install rails with database postgresql and got an error:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
*** 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.
Provided configuration options:
--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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--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-lib=${pg-dir}/
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/tmpdir.rb:92:in `mktmpdir': parent directory is world writable but not sticky (ArgumentError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:510:in `try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:534:in `try_link'
from extconf.rb:36:in `<main>'
Gem files will remain installed in /tmp/bundler20150325-70824-ipx8vh/pg-0.18.1/gems/pg-0.18.1 for inspection.
Results logged to /tmp/bundler20150325-70824-ipx8vh/pg-0.18.1/gems/pg-0.18.1/ext/gem_make.out
An error occurred while installing pg (0.18.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.18.1'` succeeds before bundling.
What can be done to fix this?
thanks, but i have solution and the problem is 32bit vs.64 bit compatibility.
ARCHFLAGS='-arch x86_64' gem install pg
Checkout this link: stackoverflow.com/questions/9668753.
This always works for me, but I also download postgres first and move to Applications directory:
Postgress.app
Install Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
If you're not sure if you have Homebrew run:
brew -v
If installed, you should get current version, such as Hombrew 0.9.5
then run:
brew install postgresql
finally:
bundle install

I get this error when I run "bundle install" with gem 'pg'. what should i do?

I get this error when I try to bundle install with pg gem. I already install postgresql gem. Please tell me what can I do? I saw the other Stackoverlfow posts and implemented them but it's still showing this error
when the bundler tries to run gem pg
Installing pg (0.17.1)
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/home/salmanalam/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
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.
Provided configuration options:
--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=/home/salmanalam/.rvm/rubies/ruby-2.0.0-p353/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-lib=${pg-dir}/
extconf failed, exit code 1
Gem files will remain installed in /home/salmanalam/.rvm/gems/ruby-2.0.0-p353/gems/pg- 0.17.1 for inspection.
Results logged to /home/salmanalam/.rvm/gems/ruby-2.0.0-p353/extensions/x86_64- linux/2.0.0/pg-0.17.1/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
Looks like you are on Linux.
Try installing libpq-dev for Debian/Ubuntu, or postgresql-devel for RHEL systems.

Installing pg -v 0.17.1

I'm using/I want to use Postgresql as database, but when I type "bundle install" or "bundle update", I get this error, what do I do to fix this? :)
Installing pg (0.17.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/rvm/rubies/ruby-1.9.3-p392/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.
Provided configuration options:
--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=/usr/local/rvm/rubies/ruby-1.9.3-p392/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-lib=${pg-dir}/lib
Gem files will remain installed in /Users/rsvmrk/.bundler/tmp/22196/gems/pg-0.17.1 for inspection.
Results logged to /Users/rsvmrk/.bundler/tmp/22196/gems/pg-0.17.1/ext/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
Any suggestions?
Looks like you are missing pre-requisite libraries.
sudo apt-get install libpq-dev postgresql-devel
Then install pg
gem install pg
For those on OS X, I recommend using home-brew to install:
brew install postgresql
More info at Homebrew's site, if you're not already a user, including how to set it up.
in order to communicate with a PostgreSQL database backend you need the libpq-dev package.
sudo apt-get install libpq-dev
then continue the package installation
gem install pg

Resources