Setting Environment variables via run on RHEL

74 views
Skip to first unread message

chris.a....@gmail.com

unread,
Oct 27, 2006, 11:03:19 AM10/27/06
to Capistrano
I'm running a Rails app which uses the Oracle database adapter. One of
the things required by the underlying Oracle client is to have the
ORACLE_HOME environment variable set properly (or the driver chokes
whenever Rails is loaded).

I'm using bash, and my bashrc file isn't getting loaded. But I also
can't seem to set the environment variables via run commands in a task
that gets fired off before any other actions.

I have the following task:

task :env_dump, :roles => :app do
run "ORACLE_HOME=/opt/oracle/instantclient_10_2"
run "echo $ORACLE_HOME"
run "echo $PATH"
end

The path gets echoed out, but nothing gets spit out after the echo
$ORACLE_HOME line. I've also tried executing a script which sets the
environment, but that doesn't seem to work either. Until I can properly
set the environment variables, deployment needs to be done manually by
logging in (where the environment does get set up as soon as I login
via my .bashrc file).

Has anyone else seen this? Has anyone been able to get around it?

chris.a....@gmail.com

unread,
Oct 27, 2006, 11:15:24 AM10/27/06
to Capistrano
So after some digging, I've managed to find a way to get it to work:

First, I monkeypatched Capistrano as mentioned in the earlier thread:
capistrano, .bashrc, Debian and RedHat
http://groups.google.com/group/capistrano/browse_thread/thread/a59ce635c15d41d4

Next I had to set :use_sudo to false in my deploy.rb:
set :use_sudo, false

Both of these together seem to work (but it seems a little ugly).

Reply all
Reply to author
Forward
0 new messages