Wrong Environmental variables in $PATH from Octopus server


Deployments are failing since the environmental variables octopus server are getting from the path are no complete.
For example “ip” command works as expected locally on the server but it is not found on the path from the Octopus server

Output from Octopus server:
Hostname server1.example.com
Whoami octopus
Echo “$PATH” /usr/local/bin:/usr/bin
Which ip which: no ip in (/usr/local/bin:/usr/bin) Error
The remote script failed with exit code 1 Fatal

Output logged in locally on the server
[octopus@server1~]$ hostname;whoami;echo “$PATH”; which ip
Why Octopus server is not getting the right path ?

Tentacles are fully updated. Octopus verison 2020.1.18

Hi jscvictormanuel,

Thank you for reaching out to us with your query.

Octopus will be using the $PATH variable that is provided to it by the operating system. The most likely explanation for the difference is that the server is configured to provide a different path depending on the user, connection method or some other factor.

Can you please advise on the following?

  • Is this script running directly on the Octopus Server, in a worker or on a Tentacle? Is any form of containerisation in use? If a Tentacle which connection type is being used?

  • When you run the commands manually are you logged in using the same method as Octopus? For example, if Octopus is connecting using SSH, do you see the same issue when using SSH?

  • Has this process worked previously? If yes, has anything changed recently (such as an operating system upgrade)?

Best Regards,


Hi Charles,
Thank you for your quick response.

  • The script is running in a SSH Linux Tentacle

  • Yes, local logging (where the $PATH is show as it is, and it works as expected) is done via SSH, same as the Octopus connection

  • The difference between when it works and it does not (different machines), is the user used to connect the tentacle. If the user is “root”, Octopus get the $PATH right, if the user is “Octopus”, Octopus server strips out the " /usr/local " from the $PATH

Have a nice weekend

Hi jscvictormanuel,

Thank you for getting back to me.

It sounds like Octopus is logging in as a different user. Would you be able to confirm what happens in each of the following situations?

  • If you connect manually, using SSH, as the user “Octopus”, what is the value of $PATH?
  • If you connect manually, using SSH, as the user “root”, what is the value of $PATH?
  • If Octopus connects, using SSH, as the user “Octopus”, what is the value of $PATH?
  • If Octopus connects, using SSH, as the user “root”, what is the value of $PATH?

Please let me know if you have any questions.

Best Regards,


Hello Charles,

Yes we are using an Octopus user to connect to the tentacles rather than root

  • Local SSH Octopus user $PATH:

  • Local SSH root user $PATH:

  • Octopus connect via Octopus user $PATH:

  • Octopus connect via root user $PATH:

Thank you

Hi @jscvictormanuel!

Just jumping in for Charles here, as he’s away this week.

What’s likely happening here is that these are being set in your .bashrc file, which has an explicit call to exit if bash is not being run interactively when called through Octopus (but it is via an interactive SSH session).

If you look in your .bashrc, you should see the lines at or near the top:

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;

To get around this, you could put your path mods in an $HOME/.ssh/environment file, or if this changes a lot, you could add it before the above code block to set it even for non-interactive sessions.

I hope this helps!

Hi justin!

Sorry for taking so long to come back to you.

You were right, we did find the issue was related with what $PATH were being loaded remote vs local.

It is solved,

Thank you very much

Hi jscvictormanuel,

Thank you for letting us know, we’re glad to hear that this is working.

If you have any other questions please reach out to us again.

Best Regards,


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.