I have an Automator workflow and one of the actions is to clone a repository. Here's the code for the 'Run Shell Script' action. The command is run within the Bash shell /bin/bash
if that matters:
SOURCEDIR="${3/\/Volumes/}"
cd "$2"
REPOURL="bob@somedomain.com:$SOURCEDIR"
WORKINGDIR="$1"
# Capture any errors with cloning process in log file
git clone "$REPOURL" "$WORKINGDIR" &> ./log.txt
// For debugging
echo "exit code: $?"
echo "PPID: $PPID"
open .
Now the Automator App runs fine on my machine. The path to git on my machine (A Macbook Pro) is: /usr/bin/git
(I believe I installed git on my machine through Xcode)
But on my co-worker's machine (Also a Mac Pro) the Automator App fails. In fact, the output of the log.txt file says: bash: git: command not found
Now on my co-worker's machine the path to git is: usr/local/git/bin
, which, yes, is different because he installed git through the Google Git Installer for Mac OS X, but I didn't think it should matter because in the script the git command is not absolute path to the command and further more my co-worker can run git normally from a Bash script but when invoked directly from the Terminal.
So what gives? Why does the automator workflow work for me but not for my co-worker?
There must be something fundamental about Bash or Unix that I'm not understanding here but I'm lost.
Best Answer
Scripts run via Automator use the default search path which usually does not include
/usr/local/bin
. In your case an easy fix would be to putsomewhere at the beginning of the script.