custom env vars with rvmsudo
I am trying to run a ruby script which needs root access for some of its tasks. I know that rvmsudo exists and I use it, but if I want to set up an env var such as TEST_ENV=1
, it doesn't work.
Example:
rvmsudo ruby some_script_which_requires_root_access.rb
When I debug the script and examine the ENV
hash, I don't see the TEST_ENV=1
var. I have tried exporting the var via:
export TEST_ENV=1
and put this in .rvmrc
, in .bash_profile
and .bas开发者_Go百科hrc
for the current_user
, and also in .profile
and .bashrc
of the root user but doesn't work.
So my question is, where should I define or export this TEST_ENV=1
so that when I run the script with rvmsudo
it is part of the ENV
ruby hash?
you can try with:
sudo -E ruby some_script_which_requires_root_access.rb
it preserves your entire environment. so it should work as expected.
Did you try simply editing the rvmsudo script and putting the envvar definition in there?
精彩评论