I am using the Ruby on Rails 3.1 pre version. I like to use PostgreSQL, but the problem is installing the pg
gem. It gives me the following error:
Under CentOS 6.5 (Squeeze) I created a file:
$ sudo touch /etc/profile.d/psql.sh
with content:
pathmunge /usr/pgsql-9.3/bin
Note here, you should set your PostgreSQL path with the pg_config file. You can find this with the command:
$ sudo find / -iname pg_config
Save the file:
$ sudo chmod +x /etc/profile.d/ruby.sh
and try to execute your command again.
Note: Anytime you change the Bash configuration - changing the profile.d configuration - you should reload Bash.
For AltLinux
the package postgresqlx.x-devel
(in my case postgresql9.5-devel
) must be installed:
apt-get install postgresql9.5-devel
On Ubuntu, install the "libpq-dev" to get rid of this issue.
sudo apt-get install libpq-dev
I had the same problem on Mac OS, but I installed the PostgreSQL gem easily by using the following in a terminal:
ARCHFLAGS="-arch x86_64" gem install pg
(I installed PostgreSQL first with brew install postgresql
.)
On FreeBSD (9.1) the necessary package is /usr/ports/database/postgresql-server* which when installed will also install the required header file that makes the gem install of "pg" fail. This answer here helped me find the solution but the difference in package names required a bit of searching.
Hopefully this helps someone avoid a bit of head scratching when searching for the "-dev" package on a FreeBSD system!
On Mac OS X run like this:
gem install pg -- --with-pg-config=***/path/to/pg_config***
***/path/to/pg_config***
is path to pg_config