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 .bashrc 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:
it preserves your entire environment. so it should work as expected.