The problem that I'm now seeing is that the path is incorrrect. When I log into sudo su - cruise and I type which gem. I see the path:
/home/cruise/.rvm/rubies/ruby-1.8.7-p302/bin/gem. See the results below:
cruise@cruise-agent-laptop:~$ sudo su - cruise
[sudo] password for cruise:
cruise@cruise-agent-laptop:~$ which gem
/home/cruise/.rvm/rubies/ruby-1.8.7-p302/bin/gem
When I run the exec command which rake through go. I get the following /usr/bin/gem. You can see the output below. Why the descrepency? I need it to be /home/cruise/.rvm/rubies/ruby-1.8.7-p302/bin/gem.
[cruise] Start to execute
task: <exec command="which" args="gem" />. Current status: passed
[cruise] setting environment variable 'CRUISE_SERVER_URL' to value 'https://127.0.0.1:8154/cruise/' (Deprecated. Use 'GO_SERVER_URL' instead.)
[cruise] setting environment variable 'GO_SERVER_URL' to value 'https://127.0.0.1:8154/cruise/'
[cruise] setting environment variable 'GO_PIPELINE_NAME' to value 'Mosaic2'
[cruise] setting environment variable 'GO_PIPELINE_COUNTER' to value '19'
[cruise] setting environment variable 'GO_PIPELINE_LABEL' to value '19'
[cruise] setting environment variable 'GO_STAGE_NAME' to value 'defaultStage'
[cruise] setting environment variable 'GO_STAGE_COUNTER' to value '1'
[cruise] setting environment variable 'GO_JOB_NAME' to value 'defaultJob'
[cruise] setting environment variable 'CRUISE_PIPELINE_NAME' to value 'Mosaic2' (Deprecated. Use 'GO_PIPELINE_NAME' instead.)
[cruise] setting environment variable
'CRUISE_PIPELINE_COUNTER' to value '19' (Deprecated. Use 'GO_PIPELINE_COUNTER' instead.)
[cruise] setting environment variable 'CRUISE_PIPELINE_LABEL' to value '19' (Deprecated. Use 'GO_PIPELINE_LABEL' instead.)
[cruise] setting environment variable 'CRUISE_STAGE_NAME' to value 'defaultStage' (Deprecated. Use 'GO_STAGE_NAME' instead.)
[cruise] setting environment variable 'CRUISE_STAGE_COUNTER' to value '1' (Deprecated. Use 'GO_STAGE_COUNTER' instead.)
[cruise] setting environment variable 'CRUISE_JOB_NAME' to value 'defaultJob' (Deprecated. Use 'GO_JOB_NAME' instead.)
[cruise] setting environment variable 'CRUISE_REVISION' to value '305' (Deprecated. Use 'GO_REVISION' instead.)
[cruise] setting environment variable 'GO_REVISION' to value '305'
/usr/bin/gem
I thought that the path would be the same when I log in with the cruise user as the execution of a Go pipeline. As you can see above that is not true. The correct path is the one under the cruise account. How can I get the paths to match?
Comments
2 comments
With "su - go" an interactive shell is started, which sources ~/.bashrc and PATH might be defined there correctly. However when a service is started it uses a non-interactive shell, which does not look at ~/.bashrc by default.
The easiest way to fix this is to export PATH in /etc/defaults/cruise-agent (or /etc/defaults/go-agent depending on which version you have installed). Restart the agent for the change to take effect.
If you want a global variable to be available to all processes, you could also try adding it to /etc/environment (depending on which Linux distro you use).
-Yogi
Hi Felix,
RVM plays with environment variables in local shell session. If you want go to use the environment variables you have on your rvm-sourced shell, you need to run go-agent from the same shell, as the same user.
This usually means, you can't use dist-specific installer. You'll want to get .zip distribution, unzip it somewhere in your $HOME, and use agent.sh to launch it. It will run with your privileges, which is usually discouraged for security reasons.
Regards,
Janmejay
Please sign in to leave a comment.