0

enter image description here This is my automation script, the commands work fine when I run them from Terminal.

1
  • 1
    The $PATH may not be configured correctly within Automator scripts—try explicitly using /usr/local/bin/brew instead of just brew.
    – aaplmath
    Jan 5, 2021 at 21:32

1 Answer 1

1

The PATH passed to a Run Shell Script action in Automator by default is:

/usr/bin:/bin:/usr/sbin:/sbin

You need to include a PATH statement in the Run Shell Script action and or use fully qualified pathnames for any executables called.

That said, using three separate Run Shell Script actions in this use case makes the first one useless as change directory in the first Run Shell Script action has absolutely no bearing on the subsequent Run Shell Script actions. You should work all the commands into a single Run Shell Script action.

In a single Run Shell Script action you could use the following example shell script code:

PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:
cd "$HOME" || exit
brew update && brew upgrade

As coded, it does the following:

  • The PATH statement includes /usr/local/bin where I'd assume brew is.
  • If the cd command fails the script is stopped.
  • brew upgrade is only executed if brew update succeeds .

That all said, I would just use Terminal normally to perform any brew commands so as to be able to see what is going on.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .