My question is - where can I edit the LD_LIBRARY_PATH to make this
change permanent - at the moment it only works as long as I'm using
the online terminal window?
I'd revisit that if I were you. In the final deployment, you are likely
going to run the server as someone other than you. And, the .profile is
not always pulled in either.
I just tried adding ENV['LD_LIBRARY_PATH']="/usr/local/lib:#{ENV
['LD_LIBRARY_PATH']}"
to the environment.rb file
This doesn't seem to work
I also added puts ENV['LD_LIBRARY_PATH'] to see if it recognised
LD_LIBRARY_PATH
I think that LD_LIBRARY_PATH is not loaded by the application itself,
but by it's loader (part of the operating system). Setting this variable
when the application is already started doesn't work. The loader should
be instructed to load certain libs which (afaik) can only be done by
setting the variable before you start the app. This can be done by
setting it from a .bashrc or .profile (depending on your shell). Note
that these scripts are only used when starting a login shell. A better
way would be to create a shell script that loads the libs first and then
starts your server.
Any ideas on how I can access this from the environment.rb file?
Also, could you please explain why adding the path to .bash_profile is
not best practice? This seems to do the trick, at least through the
console.
If it works, it works But if you deploy it under a different user, it
breaks. E.g. if you deploy it with phusion passenger and apache, the
user that runs apache should have the path set. You could set this
globally in /etc/ld.so.conf.
LD_LIBRARY_PATH may not be resampled each time a library is loaded. I'm
not sure. The loader uses it but it gets it from the processes
environment. The question is when.
I read some articles about this and ld.so (normally linked by libc.so)
calls_dl_init_paths() when it's initializing. After this, there are no
more calls to this function. The input is drawn from the environment and
/etc/ld.so.conf. There's not a lot to do about this, other than setting
it before.
In the question above, I think it shouldn't be a problem to include
/usr/local/lib in your /etc/ld.so.conf (you need root access of course).
Another dirty hack might be to set the LD_LIBRARY_PATH and then fork.
The new process should load the newly set path, but I'm not sure if you
want to fork a complete rails stack (I've done it in the past, but
doesn't feel very right).
Okay - my hosting site have replied saying I should set the
LD_LIBRARY_PATH in the .bash_profile file.
As I explained earlier, this works fine when I'm in the console or
when I start rails manually from the remote shell
When I try to use their designated pane to start the app though, I get
the following error in my mongrel.log:
** Daemonized, any open files are closed. Look at log/mongrel.pid and
log/mongrel.log for info.
** Starting Mongrel listening at 0.0.0.0:12008
** Starting Rails with development environment...
/usr/lib/ruby/gems/1.8/gems/rmagick-2.9.1/lib/RMagick2.so:
libMagickCore.so.1: cannot open shared object file: No such file or
directory - /usr/lib/ruby/gems/1.8/gems/rmagick-2.9.1/lib/RMagick2.so
(LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:153:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:521:in `new_constants_in'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:153:in `require'
from /usr/lib/ruby/gems/1.8/gems/rmagick-2.9.1/lib/RMagick.rb:11
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`gem_original_require'
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:153:in `require'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:521:in `new_constants_in'
... etc
Anybody have any idea why this is?
Are there any other startup files I could try adding this to?
libMagickCore.so.1: cannot open shared object file: No such file or
directory - /usr/lib/ruby/gems/1.8/gems/rmagick-2.9.1/lib/RMagick2.so
(LoadError)
Anybody have any idea why this is?
I bet if you look under a similar path except add in local you will find
the library you are trying to load.
The .bash_profile isn't going to work and I'm disappointed they
suggested it.
One idea I had is to send them the error that you just pasted. They
should already have local/lib in the load path. Its just a matter of
finding someone who cares and is competent. Why have the RMagic code on
the system except for people to use. They must not know that people
can't use it.
Are there any other startup files I could try adding this to?
I don't know if this is going to work but poke around the site looking
for how and where to put an .htaccess file and then see if you can add
to the environment using Apache's mod_env facility. This might happen
happen before Mongrel or Rails is launched.