I do rails development. In this app, I need to specify the environment variable LD_LIBRARY_PATH = /usr/local/oracle/lib But when I run the app with sudo script/server, it doesn't run because that library path is not in roots' env. What should I do to make it work? I tried to put the path under root ./bashrc and it didn't work.
feedback
|
|
Crazy idea, but are you sure that the server actually runs as root? Some servers specify an account that they run under, so even though you invoke the start script as root they are actually running as another user. | |||||||
feedback
|
|
I had a similar problem. I looked in my /etc/sudoers file and I saw these lines:
Defaults env_reset
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR \
LS_COLORS MAIL PS1 PS2 QTDIR USERNAME \
LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION \
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC \
LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS \
_XKB_CHARSET XAUTHORITY"
To get my environmental variable to be there I had to add its name after "XAUTHORITY". In your case you would have:
Defaults env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR \
LS_COLORS MAIL PS1 PS2 QTDIR USERNAME \
LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION \
LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC \
LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS \
_XKB_CHARSET XAUTHORITY LD_LIBRARY_PATH"
Give that a try. Also make sure that you set BASH_ENV="~/.bashrc" in "/etc/environment" | ||||
|
feedback
|
|
There are a number of ways to do this, including the one Insyte suggests above. If, however, you need to set an environment variable that doesn't belong in /etc/ld.so.conf, you could also simply put it in /etc/environment | |||||||
feedback
|
|
If this is a redhat-family distro:
| |||
feedback
|
|
Have you tried this:
Note that there is no semicolon between setting the environment variable and running the command. | |||
|
feedback
|
|
There are ways to add it to your script, but I would suggest an easier, more robust approach would be to add the path to the config for the dynamic linker directly: $ sudo editor /etc/ld.so.conf.d/railslibs Add the path you mention in your question to that file and run That should make an env munging unnecessary. | |||||
feedback
|
|
You could try setting the environment variable from within the rails process try adding something like below in $RAILS_ROOT/config/environment.rb
you probably need to make sure this gets set before you add the require or gem statements for you oracle database bindings. | |||
|
feedback
|
|
The way you've reached your root user matters here. Different methods for "logging in" create different environments. For example:
So, if you are not getting the environment you want - you need to figure out the chain of logins that is leading you to the software you are starting. This might be something like: gdm (X) login -> terminal emulator -> bash shell -> su -> bash shell (root) -> software. However, if you just want to take the best guess, | |||
|
feedback
|