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

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.
17
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

Hello, Discovering my plist was not working since the Big Sur update, it seems the issue was my shell script was located in the ~/Documents/ folder, and seen as forbidden for security reasons. I moved my script in another folder (in ~/ ), unload and load again, and it worked.

Hello, the same happened to my system. I placed a small shell script in /usr/local/bin and it worked fine when I call it from the Terminal. After trying to load the launchctl command I got the "Load failed: 5: Input/output error" My plist file was very simple and plutil check was w/o any complains.

[mf@Server]:/Users/xyz/Library/LaunchAgents $ launchctl load local.demo.plist Load failed: 5: Input/output error Try running launchctl bootstrap as root for richer errors.




[mf@Server]:/Users/xyz/Library/LaunchAgents $ plutil local.demo.plist local.demo.plist: OK

After moving this script into /Users/xyz/ it worked fine.

Consider this small script:

% cat /usr/local/bin/greetings.sh 
#! /bin/sh

logger 'Hello Cruel World!'

It’s marked as executable:

% ls -l /usr/local/bin/greetings.sh 
-rwxr-xr-x  1 root  wheel  40  9 Jul 12:23 /usr/local/bin/greetings.sh

Now consider this launchd property list file:

% cat com.example.test665661.plist 
<?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>com.example.test665661</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/greetings.sh</string>
    </array>
</dict>
</plist>

You can load this as a job:

% launchctl load com.example.test665661.plist 

IMPORTANT Because I didn’t use sudo, this is loaded as a launchd agent in the current session.

And then start it:

% launchctl start com.example.test665661     

And in console you see this:

type: default
time: 12:32:02.647234+0100
process: logger
category: -
message: Hello Cruel World!

I ran this all on macOS 13.4.1 but it should work this way on any version of macOS that supports launchd (so 10.5 and later).

Oh, and to tidy up:

% launchctl unload com.example.test665661.plist
% rm com.example.test665661.plist 
% sudo rm /usr/local/bin/greetings.sh

Share and Enjoy

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

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