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 as System-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
and echo $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
It looks like you edited this code snippet:
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:
Then, next time you log in, PATH ought to be altered, whether
$HOME/bin
exists or not.OK, there's a couple issues here:
Use
echo $PATH
instead of$PATH
to check it!The reason for this is that bash replaces
$PATH
with the contents of that variable everywhere, so just running$PATH
tries to execute the contents of the variable, which is nonsense to hte bash interpreter.You should add the content you added to
~/.profile
to~/.bashrc
as well.Make sure that
"$HOME/bin"
exists by runningls -d $HOME/bin
. If you get an error likebash: ls: No such file or directory.
then it doesn't exist. If it does exist then you should get an output something like/home/[username]/bin
.If all those are satisfied then you should be good to go. If you're not, then just use this command:
cd [path_to_studio_directory]; ./studio.sh
instead. That way you will start inside that folder and guarantee its execution.