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

$ type studio.sh
bash: type: studio.sh: not found
  • What is the output from locate studio.sh? – WinEunuuchs2Unix Mar 31 '18 at 22:04
  • I returns 1. No output. – SlowerPhoton Mar 31 '18 at 22:07
  • @win type studio.sh might work better – wjandrea Mar 31 '18 at 22:09
  • @wjandrea type -a studio.sh might work even better :D – WinEunuuchs2Unix Mar 31 '18 at 22:10
  • It says bash: type: studio.sh: not found. I guess this implies it's not in the PATH after all. I updated the question to show the instructions I followed. The path to studio.sh is certainly correct - I tested it with cd. – SlowerPhoton Mar 31 '18 at 22:13

This is the last item in your PATH:


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.

  • You are right! It doesn't match it because I forgot I had been meddling with the variable before. – SlowerPhoton Mar 31 '18 at 22:58

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$"
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

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
  • studio.sh is defined as an executable. There are three "x"s. – SlowerPhoton Mar 31 '18 at 22:25
  • So the locate command found it? What directory is it in? – WinEunuuchs2Unix Mar 31 '18 at 22:27
  • Sorry but I don't think you've read the question. In $HOME/Installs/android-studio/bin directory. I knew it from the beginning and it is unimportant for what I want to achieve. I want to be able to type studio.sh anywhere in terminal (in any directory) and start Adroid Studio. – SlowerPhoton Mar 31 '18 at 22:30
  • @SlowerPhoton Sorry I missed that edit. – WinEunuuchs2Unix Mar 31 '18 at 22:32
  • 1
    @SlowerPhoton I added how to correctly add the path to the answer. After this your type studio.sh should find it. – WinEunuuchs2Unix Mar 31 '18 at 22:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.