1

I understand this type of question has been asked

Help me understand .profile, .bashrc, etc

Sequence of scripts sourced upon login

But I'm having a hard time understanding it.

I've got an Ubuntu machine setup so it connects to Jenkins as a slave. On this machine I've edited /etc/bash.bashrc and exported PATH with additional tools.

When I run a terminal (from the GUI) and execute

echo $PATH

I see the extra values on PATH.

When I run a sh script (from the GUI) which executes

echo $PATH

the extra values are missing.

If the same script is executed via "Startup Applications" the extra values are also missing from PATH.

Since I'm connecting to Jenkins using this approach that's a problem for me. i.e. It means my build jobs fail.

The only 'fix' I've found is to add the values to /etc/environment. When placed here the extra entries on the PATH appear in both scenarios.

But... only after the user logs back in/restarts. Which is not ideal.

How can I configure the machine so the extra entries are add to path for all scenarios?

FYI: I'm using Chef to configure the machine so it'll need to set these variables.

Shane Gannon
  • 113
  • 1
  • 6

1 Answers1

2

Setting environment variables via /etc/bash.bashrc does not make them available in the graphical environment. I would suggest that you instead create the file /etc/profile.d/myvars.sh and set the variables from there. Files in the /etc/profile.d folder with the .sh extension are sourced by the display manager, and with that made available in the whole session, including the graphical environment.

Reference: EnvironmentVariables