4

I am running linux mint 17.2, I have repo installed and the path to repo is added to my .bashrc. I have previously initiated my repo.

I have followed the instructions on the Android Source Downloading and How to Build CyanogenMod pages.

The problem is: I have written a bash script to automate a number of the commands I would like to use to start a build. My script in a simple form is the following:

#!/bin/bash
cd ~/Android/Cyanogenmod/cm12_1/android/system
source build/envsetup.sh
repo sync --force-sync -j8
exec $SHELL

When I run this, it reports:

/home/username/Desktop/Cyanogenmod_cm12_1_Grouper_Build : line 4 repo: command not found

If I copy and paste each line into a fresh terminal instance (or by just running a script of #!/bin/bash exec $SHELL to open a terminal) it works perfectly.

What I have tried: I have tried including a sleep 10 before the repo sync --force-sync -j8 but that made no difference. I have also tried explicitly initiating the repo and force adding it to my PATH for the current terminal session directly before attempting the repo sync --force-sync -j8. The code for that test was the following:

#!/bin/bash
mkdir -p ~/Android/Cyanogenmod/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/Android/Cyanogenmod/bin/repo
chmod a+x ~/Android/Cyanogenmod/bin/repo
cd ~/Android/Cyanogenmod/cm12_1/android/system/
source build/envsetup.sh
PATH=~/Android/Cyanogenmod/bin/repo:$PATH
repo sync --force-sync -j8
exec $SHELL

The following 2 questions have a similar title, but neither are my question, this and this.

Any help or suggestions would be great, thank you!

Community
  • 1
  • 1
Michael
  • 41
  • 1
  • 6
  • Too much noise in this question. Command not found is command not found, easy and simple. Your script can be boiled down to a shebang and a single command `repo`, and you'll still get the exact same error without what's described in this wall of text. – 4ae1e1 Nov 12 '15 at 08:43
  • 1
    Your error is in `PATH=~/Android/Cyanogenmod/bin/repo:$PATH`. What you need is `PATH=~/Android/Cyanogenmod/bin:$PATH`. – 4ae1e1 Nov 12 '15 at 08:45
  • Thank you! I had that in my `.bashrc` actually, just didn't try it correctly when I explicitly tried it in the same terminal session. Although, that brings up another question of why didn't it work without that line in the script? My `.bashrc` currently has: `export PATH=${PATH}:~Android/Cyanogenmod/bin` in it? – Michael Nov 12 '15 at 08:59
  • Print `$PATH` inside your script to check if you've really got the right path. – 4ae1e1 Nov 12 '15 at 09:00
  • So, if I do this: `User@User ~ $ $PATH` I get: `bash: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/michael/Android/Cyanogenmod/bin: No such file or directory` – Michael Nov 12 '15 at 09:05
  • 1
    No, I'm asking you to `echo $PATH` inside your script. – 4ae1e1 Nov 12 '15 at 09:20
  • It is indeed not there...hmmm I am currently trying to get the path added correctly to my .profile EDIT: Tonight is just not my night it appears.....Logged out and back in, all is working. I simply added `export PATH=$PATH:$HOME/Android/Cyanogenmod/bin` to the end of my `.profile` (which is where I curled my repo to), logged out/in and it shows up with `echo $PATH`, and my initial code above functions correctly. Thank you again – Michael Nov 12 '15 at 09:45

1 Answers1

0

To summarize, there turned out to be 2 problems. The first, was in my attempted solution of manually setting the path in the script as PATH=~/Android/Cyanogenmod/bin/repo:$PATH should have been just PATH=~/Android/Cyanogenmod/bin:$PATH.

The second, and overall larger problem, was an incorrectly added PATH variable (to repo) in my .bashrc. This was fixed by adding the line export PATH=$PATH:$HOME/Android/Cyanogenmod/bin to the end of my .profile, followed by logging out/in.

Michael
  • 41
  • 1
  • 6