Why does my zsh program run fine in terminal, but not as an automator app? I got a mac last week and am trying to learn the basics by coding a few projects I came up with. I've been creating a few apps I can place on the dock that automate simple functions that I use often. So far, all my programs have worked by creating a zsh script and getting Automator to 'Run Shell Script', however this particular program isn't fully working, although, if I run my program through terminal, it works perfectly.
I'm trying to create a program that can be executed after a YouTube url has been copied into the clipboard. The program takes the url and runs it through 'youtube-dl' and downloads the audio into the Downloads folder. I tried to learn how to do this from Z shell alone, but I was very overwhelmed with it and I decided to use python which I already know.
Here's what I'm doing:
My Python3 code:
import os

url = os.popen(&quot;echo `pbpaste`&quot;).read()
os.system(&quot;youtube-dl -f 'bestaudio[ext=m4a]' '&quot;+url+&quot;'&quot;)

My zsh file:
#!/bin/zsh

cd /Users/admin/Downloads
python3 /Users/admin/Documents/Scripts/Automation/ytGetAudio/ytGetAudio.py

I then made it executable with &quot;chmod +x /Users/admin/Documents/Scripts/Automation/ytGetAudio/ytGetAudio.zsh&quot;
When I run my program from the terminal, everything works great, and the file is downloaded into Downloads, but when I use Automator to &quot;Run Shell Script&quot; and I get it to run the same zsh script it doesn't download anything. I tested it by creating a pop-up message box in the python script; that worked, so the script is running, but something isn't working because nothing is downloading when I run the '.app' file.
Can anyone please help me with this?
This is the standard issue with GUI apps in macOS. These are launched via lanuchd from desktop, no part of the process has run through a shell so what is in any of your shell start up scripts e.g. $PATH does not matter.
What you need to do is use the full path to anything you call in your case the full path to youtube-dl and if that is a script that might need editing to provide full paths to what it calls.