In this article
Measure the job’s own starting point
A script that reads input.txt may work when you run it from its project folder in Terminal, then fail as a LaunchAgent. The script can be perfectly readable and its interpreter correctly configured. The missing detail is where that relative filename starts.
For a diagnostic version of your own script, print pwd near the beginning, before any directory change. Send that output to the job’s existing log. If logs are missing, first check LaunchAgent output destinations. An empty log does not establish a particular working directory.
Running pwd in your interactive Terminal measures that shell’s current location. It does not measure a separately launched job. Likewise, knowing the absolute location of the script proves where the script is stored, not where its file operations begin.
Apple’s Terminal guide to launchd provides the native service-management context. Use the job’s own output to answer the narrower directory question.
| Path or setting | What it identifies |
|---|---|
| Absolute script path | The script to start |
WorkingDirectory | The directory selected before the job runs |
Relative argument such as input.txt | A name interpreted by the receiving program |
| Absolute data-file path | A particular location independent of the current directory |
Keep data-file lookup separate from PATH
PATH helps a shell find commands named without a directory. The working directory affects ordinary relative file paths. Changing one does not automatically repair the other.
For example, /bin/cat input.txt already names its executable explicitly. If it reports that input.txt does not exist, adding another command directory to PATH does not identify the intended input file.
If the script cannot find a command at all, use LaunchAgent command lookup and PATH. This article addresses a script that starts and then looks for data in the wrong place.
Also distinguish WorkingDirectory from RootDirectory. The Apple launchd.plist source manual describes the former as a directory change before running the job; the latter concerns changing the process’s root. They are separate settings. Check man launchd.plist on the Mac running your job for its installed documentation.
Four jobs, one script, two different inputs
We tested four disposable user LaunchAgents on macOS 15.7.5, Apple Silicon, on November 13, 2026. Every job started the same script through an absolute /bin/sh path. The script printed its working directory, read its supplied filename with /bin/cat, and recorded that command’s result.
The fixture project contained input.txt with a unique marker, CORRECT_INPUT. A separate subfolder contained another input.txt with OTHER_INPUT. These were newly created test files, not application data.
| Job configuration | Observed directory | Read result |
|---|---|---|
| No WorkingDirectory; relative input | / | File not found; exit 1 |
| Fixture directory selected; relative input | Fixture project | CORRECT_INPUT; exit 0 |
| Other directory selected; relative input | Other folder | OTHER_INPUT; exit 0 |
| No WorkingDirectory; absolute input path | / | CORRECT_INPUT; exit 0 |
All four jobs registered and ran once. We removed only those temporary registrations afterward and checked that each was absent. No existing helper, system daemon or session-wide setting was changed.
The third row is the important failure that a simple success check misses. The file existed and the command returned zero, but it read the wrong file. A missing-file error is therefore only one possible symptom of an unintended working directory.
The two jobs without an explicit directory started at / in this test. That is an observation from this Mac and configuration, not a substitute for inspecting a job that uses a wrapper or changes directory itself.
Choose the smallest explicit configuration
For one input, passing its verified absolute path may be the clearest solution. Keep the executable and each argument as separate ProgramArguments array entries. An entire shell command pasted into one plist string is not the same argument structure.
For a project that deliberately uses several relative paths, a verified absolute WorkingDirectory can make that convention explicit. Enter the directory containing the resources the program expects. Do not choose the plist’s location merely because it is where the configuration file lives.
Apple’s launchd configuration guide explains the property-list approach. As a concrete maintained application example, OliveTin’s macOS service documentation uses both a working directory and an explicit configuration-directory argument. A program can have its own path options beyond the process’s starting directory.
Treat an application’s documented configuration as authoritative for that application. Do not add a WorkingDirectory override to an unfamiliar vendor helper just because a similar-looking personal script needed one.
Verify the actual input after a change
For a job you own, save the previous configuration and check the plist with plutil -lint "/path/to/job.plist", substituting its real path. This checks property-list syntax; it does not prove that a directory exists or that the intended task will succeed.
A registered job may still be using its earlier configuration. Reload only the specific job after confirming that stopping and repeating it is appropriate. Remember that RunAtLoad can execute the job immediately when it is registered. A plist merely being present is different from a LaunchAgent actually running.
On the next run, inspect the working directory and confirm which input was read. Use a harmless known marker or a relevant result you can verify; avoid dumping an entire environment or confidential configuration into public logs.
If the path is now correct but access is denied, investigate that access problem separately. The useful stopping condition is the intended task using the intended file—not simply an exit status of zero.


