Question

I'm having trouble getting a rails app on Dreamhost's Passenger to see compiled libraries in my ~/opt/lib directory. I have to put them here because I don't have root access.

I can boot up my app in ./script/console and it sees them libraries just fine because I updated my .bash_profile's LD_LIBRARY_PATH environment variable to include ~/opt/lib.

I've tried putting ENV['LD_LIBRARY_PATH'] = '~/opt/lib' in my environment.rb file but it doesn't seem too help. I get the following error from Passenger when I navigate to my site: libodbcinst.so.1: cannot open shared object file: No such file or directory - /home/username/opt/lib/odbc.so

Anyone have experience with this?

Thanks

Was it helpful?

Solution

The environment.rb way sounds like the way to go, though you might want to append to LD_LIBRARY_PATH instead. Also I'd make sure to use the full path to that directory just in case.

Alternatively you might be able to use .htaccess directives, similar to what is described @ http://wiki.rubyonrails.org/rails/pages/HowToUseOracleWithFastCGI

OTHER TIPS

I had similar issue with Passenger that I described in http://blog.rayapps.com/2008/05/21/using-mod_rails-with-rails-applications-on-oracle/

But in your case this migth not work as you will not be able to change Dreamhost's httpd.conf file.

Other thing that you can try is to set LD_LIBRARY_PATH in .bashrc - according to http://www.wavethenavel.com/jonathanpenn/2008/09/08/bootstrapping-a-dreamhost-account-for-rails-and-git/ this has worked in Dreamhost's case. Have not verified that Passenger will execute .bashrc before launching ruby.

Using .bashrc won't work, as the library path that Passenger uses is the one that Apache loads on boot. There is no way it would look at a user's directory as that would be a major security issue.

This is an old thread, but for completeness this is how to achieve your goal:

  1. Do not set the LD_LIBRARY_PATH if possible - it's horrendous.
  2. As you do not have control over the environment that the Apache user's environment, attempting to set a LD_LIBRARY_PATH env var per the methods above will not work anyway.
  3. Set the LDFLAGS environment variable with link and record path flags set prior to compiling the library files to set the correct search paths - e.g.:

    export LDFLAGS="-L$HOME/opt/lib -R$HOME/opt/lib"

Once compiled, the files will have the correct links set to the relevant libraries. You can check this using the ldd command line tool - e.g.:

ldd /$HOME/your/custom/complied/library/file.so
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top