Search code examples
ruby-on-railslinuxpostgresqlamazon-ec2pg

Problem installing pg gem properly


I have a rails app that I am trying to get running in an Amazon EC2 instance. This app has been tested properly on various Linux, OS X and Windows systems.

On the EC2 server, I have built PostgresSQL 9 from source. At first, the 'pg' gem wouldn't install but I built it with the following command:

gem install pg -- --with-pgsql-lib=/usr/local/pgsql/lib --with-pgsql-config=/usr/local/pgsql/bin/pg_config

This seemed to build properly. However, when I run a rake task, such as 'rake db:migrate' I get the following error:

rake aborted!
libpq.so.5: cannot open shared object file: No such file or directory - /home/ec2-user/.rvm/gems/ruby-1.8.7-p334/gems/pg-0.11.0/lib/pg_ext.so

Solution

  • From the error message and your description of your 'find' command output, it's possible that /usr/local/pgsql/lib is not in the path the dynamic linker searches for its libraries. Try adding that directory to /etc/ld.so.conf (or similar), or set LD_LIBRARY_PATH to include it before you run rake.