Search code examples
macosshortcut

Why doesn't shell scripts in Shortcuts see my utilities?


i tried using shortcuts. i wanted to run scripts there, but i constantly get an error that the brew utility was not found. it feels like the scripts run in isolation.

i tried use

  1. brew link php
  2. eval 'brew link php'
  3. sh fileWithMyScript.sh

and always got error. how to fix it?

enter image description here

enter image description here enter image description here


Solution

  • The brew command is not in macOS default PATH. You will either have to use the full path to the command or set PATH before calling the command:

    /opt/homebrew/bin/brew link php
    PATH=$PATH:/opt/homebrew/bin brew link php
    PATH=$PATH:/opt/homebrew/bin cd ~/utils && sh php_8.1.sh
    

    Use a different directory than /opt/homebrew/bin if homebrew is installed elsewhere.