0

How do you add a full path to the PATH variable using Bash? I've tried for example somthing like

export PATH=/myPath:$PATH

but it doesn't work.

4
  • This is fine, where did you do this export? Commented Jan 11, 2014 at 15:32
  • on the command line using my Linux machine. Commented Jan 11, 2014 at 15:35
  • ok and what exactly is not working after that export? Commented Jan 11, 2014 at 15:40
  • so there's a program on my computer that checks whether this path was added to the PATH variable or not and apparently it's stating that it's not. Commented Jan 11, 2014 at 15:43

2 Answers 2

1

The export command only takes effect in the current shell, for all programs started subsequently to that export command.

To make it take effect for other shells, and after you logout, you'll need to add the command to your ~/.bashrc file and restart the other terminal windows/tabs.

To make it take effect for GUI applications when they are not started directly or indirectly from a terminal window, an additional step may be required.

To make it take effect for applications running as another user (e.g. root), a different additional step may be required.

Sign up to request clarification or add additional context in comments.

Comments

0

The code you mentioned above works perfectly well: PATH variable gets changed - for current bash session and all processes started from it.

The source of the problem is probably the following:

Your program gets a copy of environment variables on it's start. If environment variable (PATH or anything else) is changed after the program start, the program will not "see" the change. You'll need to restart a program.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.