Reproducing execution launchd execution environment
Launchd jobs run with a default shell that does not import any of the typical environment variables you'll see in an interactive shell; in particular the PATH variable lacks any directories that your interactive shell might have added, which can cause headaches. You can work around that two ways:

By making your script as thoroughly generic as possible: using full path specifications to every command and utility, and explicitly setting variables as you need them rather than relying on the environment.
By adding an EnvironmentVariables dictionary to your launchd plist file and specifying the environment there.

The second looks like this:
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
    &lt; ... &gt;
    &lt;key&gt;EnvironmentVariables&lt;/key&gt;
    &lt;dict&gt;
           &lt;key&gt;VARIABLE_NAME_1&lt;/key&gt;
           &lt;string&gt;variable_contents&lt;/string&gt;
           &lt;key&gt;VARIABLE_NAME_2&lt;/key&gt;
           &lt;string&gt;variable_contents&lt;/string&gt;
    &lt;/dict&gt;
    &lt; ... &gt;
&lt;/dict&gt;
&lt;/plist&gt;