You can export it as many times as you want, it will make no difference (after the first export, obviously).
All export
does in this context (other than changing the variable itself due to the =
) is mark a variable so that it's exported to the environment of future commands.
You can mark it so as much as you want. The effect of the two commands:
export PATH="/usr/local/heroku/bin:$PATH"
export PATH=$PATH:/opt/AWS-ElasticBeanstalk-CLI-2.6.0/eb/linux/python3/
will be to mark PATH
as an export variable (it probably is so already since you generally want your path to be inherited) and set it to:
/usr/local/heroku/bin:$PATH:/opt/AWS-ElasticBeanstalk-CLI-2.6.0/eb/linux/python3/
where $PATH
was the path before executing those commands.
The only thing you need to be careful of is the ordering. For example, if /usr/local/heroku/bin
contains an executable program called ls
, that's probably going to make life difficult for you if you're trying to get a directory listing. For that reason, I tend to add directories only to the end of the path.
Alternatively, you can make the order less permanent by providing an alias or function which changes your path to the Heroku-preferred one only for the current session.
Keep in mind that the files that get run by bash
are a complex matter. .bashrc
is run for interactive, non-login shells so may not run in all cases (I, for one, fix that by calling .bashrc
at the end of my .bash_profile
though some people may cringe at that).
You're probably better off setting (and exporting) the path in your .bash_profile
.
And, if there is something wrong with what you're doing (your syntax seems fine but there may be other problems we cannot discern due to lack of information), you should perform the following steps:
echo $PATH
before and after each export
command to see if something is stuffing it up.
- ensure that each component in the path actually exists (i.e., that you have the correct directories in there).
.bashrc
isn't generally the right place to update your PATH -- you'll get entries added multiple times as shells started by other shells invoke it after it's already been run by a parent. Environment updates generally belong in.bash_profile
, so they're run only once per login. – PacePATH
you're getting, so we can tell why you think anything is wrong. – Pace