5

In the installation instructions for Android Studio they say:

3. [OPTIONAL] Add "{installation home}/bin" to your PATH environment
 variable so that you may start Android Studio from any directory.

I did that according to this Stack Overflow question. But how do I start it now? The problem is I need to execute a shell script studio.sh and I am afraid these are not visible for the PATH variable.

I should be able to call it in any directory in terminal by calling just studio.sh.

EDIT: more info

studio.sh runs the Android Studio

I followed the official installation instruction which came with the android-studio zip file (form official website).

I added

export PATH=$PATH:$HOME/Installs/android-studio/bin

at the end of ~/.profile.

Adding more outputs:

$ ls -l $HOME/Installs/android-studio/bin/studio.sh
-rwxr-xr-x 1 roman roman 6985 bře 21 18:26 /home/roman/Installs/android-studio/bin/studio.sh

$ echo $PATH
/home/roman/bin:/home/roman/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/roman/Installs/android-studio/bin/studio.sh

$ type studio.sh
bash: type: studio.sh: not found

2 Answers2

3

This is the last item in your PATH:

/home/roman/Installs/android-studio/bin/studio.sh

The problem is that items in the PATH need to be directories but you've added a file. I'm not sure how this happened since it doesn't match the export PATH=... line you posted.

wjandrea
  • 14,504
0

First find out what directory studio.sh is in so you can add it to the path. Consider the following:

rick@alien:~$ locate --regex "wpasupplicant$"
/etc/network/if-down.d/wpasupplicant
/etc/network/if-post-down.d/wpasupplicant
/etc/network/if-pre-up.d/wpasupplicant
/etc/network/if-up.d/wpasupplicant
/lib/systemd/system-sleep/wpasupplicant
/mnt/e/lib/systemd/system-sleep/wpasupplicant
/usr/share/doc/wpasupplicant
/usr/share/lintian/overrides/wpasupplicant
───────────────────────────────────────────────────────────────────────────────────────────
rick@alien:~$ which wpasupplicant
───────────────────────────────────────────────────────────────────────────────────────────
rick@alien:~$ type wpasupplicant
bash: type: wpasupplicant: not found
───────────────────────────────────────────────────────────────────────────────────────────
rick@alien:~$ ll /lib/systemd/system-sleep/wpasupplicant
-rwxr-xr-x 1 root root 182 Oct 26  2015 /lib/systemd/system-sleep/wpasupplicant*

The file wpasupplicant is defined as an executable as defined by the x in -rwxr-xr-x.

There is also a remote possibility studio.sh isn't defined as an executable and still in the path. In this case the which and type commands will not find it but the locate command will still find it.

If the file was just created

Consider if the file was just created:

rick@alien:~$ cp .rm-kernels-ndx asdf.asdf
───────────────────────────────────────────────────────────────────────────────────────────
rick@alien:~$ locate asdf.asdf
───────────────────────────────────────────────────────────────────────────────────────────
rick@alien:~$ time sudo updatedb

real 0m3.460s user 0m0.503s sys 0m1.167s ─────────────────────────────────────────────────────────────────────────────────────────── rick@alien:~$ locate asdf.asdf /home/rick/asdf.asdf

You need to run sudo updatedb for locate command to find newly created files. The program updatedb is called automatically by cron but newly created files may not appear. After comments on this thread I decided to change my own sudo crontab -e to run /usr/bin/updatedb every five minutes.

After you find the directory

To add your directory to the path edit ~/.profile and add the following:

if [ -d "$HOME/Installs/android-studio/bin" ] ; then
  PATH="$PATH:$HOME/Installs/android-studio/bin"
fi