I tried using gem install pg
but it doesn\'t seem to work.
gem install pg
gives this error
Temporarily enhancing PATH to in
For Mac Users
PATH=$PATH:/Library/PostgreSQL/9.4/bin/ gem install pg
This should do the trick
Regardless of what OS you are running, look at the logs file of the "Makefile"
to see what is going on, instead of blindly installing stuff.
In my case, MAC OS, the log file is here:
/Users/za/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-1.0.0/mkmf.log
The logs indicated that the make file could not be created because of the following:
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers
Inside the mkmf.log, you will see that it could not find required libraries, to finish the build.
checking for pg_config... no
Can't find the 'libpq-fe.h header
blah blah
After running "brew install postgresql"
, I can see all required libraries being there:
za:myapp za$ cat /Users/za/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-darwin-15/2.3.0-static/pg-1.0.0/mkmf.log | grep yes
find_executable: checking for pg_config... -------------------- yes
find_header: checking for libpq-fe.h... -------------------- yes
find_header: checking for libpq/libpq-fs.h... -------------------- yes
find_header: checking for pg_config_manual.h... -------------------- yes
have_library: checking for PQconnectdb() in -lpq... -------------------- yes
have_func: checking for PQsetSingleRowMode()... -------------------- yes
have_func: checking for PQconninfo()... -------------------- yes
have_func: checking for PQsslAttribute()... -------------------- yes
have_func: checking for PQencryptPasswordConn()... -------------------- yes
have_const: checking for PG_DIAG_TABLE_NAME in libpq-fe.h... -------------------- yes
have_header: checking for unistd.h... -------------------- yes
have_header: checking for inttypes.h... -------------------- yes
checking for C99 variable length arrays... -------------------- yes
This worked in my case:
sudo apt-get install libpq-dev
I used:
On macOS (El Capitan). You can simply use: brew install postgresql
You just go to here to see if your pg version support Win32 platform, then use this command to install:
gem install pg -v 0.14.1 --platform=x86-mingw32
Issue is gem dependency so before installing pg make sure you have installed "libpq-dev"
Ubuntu systems:
sudo apt-get install libpq-dev
RHEL systems:
yum install postgresql-devel
Mac:
brew install postgresql