Big Sur - LaunchAgents - Load error 5: input/output error

Hi all,

I am having a mysterious problem trying to load a user LaunchAgent under Big Sur - It is the .plist of gniemetz's automount.sh
Code Block
 https://github.com/gniemetz/automount
for mounting SMB shares via pwd access from the Keychain -

Placed the .sh into /usr/local/bin, chmod 644 and chown user:staff

Placed the LaunchAgent .plist into ~/Library/LaunchAgents (created LaunchAgents it as it didn't exist), same chmod/chown.

Code Block ~/Library
drwxr-xr-x 3 users 96 Nov 1 22:13 LaunchAgents
~/Library/LaunchAgents
-rw-r--r-- 1 users 1038 Nov 1 22:13 it.niemetz.automount.plist
/usr/local
drwxr-xr-x 4 root wheel 128 Nov 1 21:52 bin
/usr/local/bin
-rwxr-xr-x 1 root wheel 30310 Oct 29 21:58 automount.sh

then the following:
Code Block launchctl load -w ~/Library/LaunchAgents/it.niemetz.automount.plist
Load failed: 5: Input/output error

For the life of me, I cannot find anywhere what this means...

Code Block
launchctl start ~/Library/LaunchAgents/it.niemetz.automount.plist

completes with no errors, syntax also parses OK

Code Block plutil -lint ~/Library/LaunchAgents/it.niemetz.automount.plist
/Users//Library/LaunchAgents/it.niemetz.automount.plist: OK

I have added Terminal and /bin/bash to Full Disk Access under Security...

Launching the script manually as /usr/local/bin/automount.sh works fine.

Console shows

Code Block launchctl load:
system.log shows this when load -w is run:
00:27:14 mac-mini-Big-Sur com.apple.xpc.launchd[1] (com.apple.xpc.launchd.user.domain.1000002.100006.Aqua): entering bootstrap mode
Nov 3 00:27:14 mac-mini-Big-Sur com.apple.xpc.launchd[1] (com.apple.xpc.launchd.user.domain.1000002.100006.Aqua): exiting bootstrap mode


For easy reference the .plist is pasted at the end -

Anyone seen this error before?

Thanks!
  • ++

Code Block
Label
it.niemetz.automount
LimitLoadToSessionType
Aqua
RunAtLoad
WatchPaths
/etc/resolv.conf
/Library/Preferences/SystemConfiguration/NetworkInterfaces.plist
/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist
ProgramArguments
/usr/local/bin/automount.sh
--mountall

Answered by DTS Engineer in 807389022
It's like they don't want developers to use it.

Actually, that’s kinda right. We always intended to create a proper API for managing launchd jobs it’s just that for… well… reasons… it took a long time coming. In the meantime, the only alternative was to mess around with launchd property lists and launchctl )-:

The good news is that there are much better options these days:

  • Many of the things that you’d previously did with a launchd daemon are now done with a system extension, managed via the System Extensions framework.

  • For other stuff, you have the SMAppService API.

In both cases the system is responsible for managing the launchd property list, which avoids many of the issues being discussed in this thread. If you can adopt these APIs, I recommend that you do so.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Had the same thing when trying to start a LaunchAgent with this plist file:

Code Block
[...] XML version, etc.
<plist version="1.0">
<dict>
<key>Label</key>
<string>gnu.emacs.daemon</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/Cellar/emacs-mac/emacs-27.1-mac-8.0/Emacs.App</string>
<string>--daemon</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

I encounter the exact same problem, with this plist file:
Code Block language
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.zerowidth.launched.auto_delete_folder_cleanup</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>find ~/Desktop/AUTO_DELETE -mindepth 1 -mtime +30 -delete</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>23</integer>
<key>Minute</key>
<integer>0</integer>
<key>Weekday</key>
<integer>1</integer>
</dict>
<dict>
<key>Hour</key>
<integer>23</integer>
<key>Minute</key>
<integer>0</integer>
<key>Weekday</key>
<integer>3</integer>
</dict>
<dict>
<key>Hour</key>
<integer>23</integer>
<key>Minute</key>
<integer>0</integer>
<key>Weekday</key>
<integer>5</integer>
</dict>
</array>
<key>UserName</key>
<string>XXXXXX</string>
</dict>
</plist>


I'm having the same issue with this plist:

Code Block xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>hotel</string>
<key>ProgramArguments</key>
<array>
<string>/Users/esbanarango/.nvm/versions/node/v12.18.4/bin/node</string>
<string>/Users/esbanarango/.nvm/versions/node/v12.18.4/lib/node_modules/@envoy/hotel/lib/daemon/bin.js</string>
<string>start</string>
<string>--hotel-dir</string>
<string>/Users/esbanarango/.hotel</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/Users/esbanarango/.hotel/daemon.log</string>
<key>StandardErrorPath</key>
<string>/Users/esbanarango/.hotel/daemon.log</string>
</dict>
</plist>


I had a LaunchAgent that would give the same error message:
Code Block
Load failed: 5: Input/output error

For whatever reason, the job had been marked as "disabled" for my user account and so I had to reenable it with:
Code Block
launchctl load -w path/to/plist


I had a similar issue with my plist file.
The problem was that the file included special characters which i tried to execute with launchctl. After I removed the bad characters the plist loaded successfully.
Check with "plutil" for proper file format.
I had a similar problem which was caused by previous load of service. launchctl unload followed by launchctl load resolved the issue.
19
I ran into this error while working on CI automation. Read steipete.com/posts/apple-silicon-mac-mini-for-ci for details.

The main fix was that the user you're using here for must be LOGGED IN. Just ssh'ing into won't be enough and you run into either this error or error 125.
I have the same problem with next pplist
[...] XML version etc.
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.atlassian.bamboo</string>
Code Block
<key>UserName</key>
<string>dev</string>

<key>ProgramArguments</key>
<array>
<string>/Users/dev/bamboo/bin/start-bamboo.sh</string>
</array>
Code Block
<key>SessionCreate</key>
<true/>

<key>RunAtLoad</key>
<true/>
Code Block
<key>KeepAlive</key>
<true/>
</dict>
</plist>
i have try to reload plist,it's ok now.

unload, and load again
I got the same issue after updating to BigSur.

What I did to solve it was to unload and load the plist

launchctl unload /path/to/plist
launchctl load /path/to/plist

What I did to solve it was to unload and load the plist

Well, that’s weird. Did you, or anyone else, file a bug about that? If so, what was the bug number?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

There are a few possible causes of / solutions to this error, some of which are detailed in previous responses. To hopefully help people coming across this as I did, I'll aggregate the solutions and add the one that worked in my case (adding .plist to the filename).

For sake of example, let's say we're adding a launch agent for the user "johnny" whose service name is "com.appleseed.runthings".

  • Make sure your filename ends in .plist, e.g. /Users/johnny/Library/LaunchAgents/com.appleseed.runthings.plist
  • Check the syntax of the file: plutil /Users/johnny/Library/LaunchAgents/com.appleseed.runthings.plist
  • Unload and reload your service:
    • launchctl unload /Users/johnny/Library/LaunchAgents/com.appleseed.runthings.plist
    • launchctl load /Users/johnny/Library/LaunchAgents/com.appleseed.runthings.plist
  • Force load in case your job has been disabled: launchctl load -w /Users/johnny/Library/LaunchAgents/com.appleseed.runthings.plist

chmod 755 your plist file

I fixed all of my issues like this by using load -w and unload -w`

I have tried all of these on M1 with no success so far. After unloading the plist and running launchctl print we still see the labeled in a disabled format. Load and unload do not seem to work in Monterey M1 . The label is loaded but after a crash or force quit the app does not restart properly. All we get is the Problem Reporter ui reporting the crash and asking to reopen but launchctl does not restart the app

Big Sur - LaunchAgents - Load error 5: input/output error
 
 
Q