Question

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
Was it helpful?

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.

OTHER TIPS

Did the trick for me on EC2 for pg gem:

sudo yum install postgresql-devel

Weird. I backed out RVM completely and re-did everything exactly the same way but this time with the ARCHFLAGS set. It occurred to me that I had forgot to set it.

env ARCHFLAGS=" -arch x86_64"

The only way I could solve this was by adding a symlink so it could find it.

ln -s /usr/pgsql-9.2/lib/libpq.so.5.5 /usr/lib/libpq.so.5
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top