Add android-studio/bin/ to PATH environmental variable
It looks like you edited this code snippet:
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
which is included in ~/.profile
by default.
The answer which lead you to do so is confusing IMNSHO.
I'd suggest that you change that code back to what it looked like before, and instead add a new line underneath it:
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
PATH="$PATH:/usr/local/Android/android-studio/bin"
Then, next time you log in, PATH ought to be altered, whether $HOME/bin
exists or not.
Related videos on Youtube
hasanghaforian
Updated on September 18, 2022Comments
-
hasanghaforian over 1 year
Recently I installed Android Studio. Now I want to add android-studio/bin/ persistently to PATH environmental variable as
Session-wide environment variables
and not asSystem-wide environment variables
. To do that I tried to edit~/.profile
as described here. So I have these at the end of~/.profile
:if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH:/usr/local/Android/android-studio/bin" fi
Then I re-login to initialize the variable. But when I run
studio.sh
in terminal, I get this:studio.sh: command not found
Here are results of
$PATH
andecho $PATH
:$ $PATH bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games: No such file or directory $ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Also I'm sure that
~/.bash_profile
and~/.bash_login
do not exist. Now what cause the problem and how I can solve that?Edit:
I change end of
~/.profile
to this, but it does not work:# set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" PATH="$PATH:/usr/local/Android/android-studio/bin" fi
-
hasanghaforian over 8 yearsWhy I have to add that to
~/.bashrc
when I did not that here:help.ubuntu.com/community/EnvironmentVariables. Also how I can check the existence of$HOME/bin
? -
Gunnar Hjalmarsson over 8 years@hasanghaforian: That recommendation makes no sense to me either.
-
Daniel over 8 yearsBecause
~/.bashrc
always gets run when you enter Terminal. It's just another check to ensure that it happens. See edit for checking existence @hasanghaforian -
Gunnar Hjalmarsson over 8 yearsIf you use
~/.profile
to edit PATH, which is an environmental variable, the new value is available in the whole session, whether you use the terminal or not. If you do it right, you don't need "another check". ;) -
hasanghaforian over 8 yearsI tried that, but it does not work. I edited question, please see it again.
-
Gunnar Hjalmarsson over 8 years@hasanghaforian: Ok, I edited my answer too to clarify.
-
hasanghaforian over 8 yearsThank you for your attention and help! But if I would to add another path, I have to add another line?
-
Gunnar Hjalmarsson over 8 years@hasanghaforian: Not necessarily. The point is that it shouldn't be between
if
andfi
. As long as you keep it where it is now, you can sayPATH="$PATH:/some/directory:/some/other/directory"
-
Daniel over 8 yearsWell, I've run into cases where
~/.profile
doesn't get processed at all, so I don't trust it as much... -
Nick Pineda over 7 yearsOnce the path what is the command to execute the program globally?
-
Gunnar Hjalmarsson over 7 years@NickPineda:
studio.sh
, I suppose. (I don't use the program myself.)