Hello! Here is some simple scenario:
- There is an app installed, let's say
/Applications/Xcode.app - That app hosts a
LaunchAgent, which is using newBundleProgramkey, e.g.Contents/MacOS/helper - User decides to rename the app to
Xcode14.2.app - When the time comes for
helperto run, it can't
It looks like launchd still tries to access helper by its old path, not new one (/Applications/Xcode12.4.app/Contents/MacOS/helper)
From launchd.log:
<Warning>: Could not find and/or execute program specified by service: 2: No such file or directory: Contents/MacOS/helper
<Error>: Service could not initialize: access(/Applications/Xcode.app/Contents/MacOS/helper, X_OK) failed with errno 2 - No such file or directory, error 0x6f - Invalid or missing Program/ProgramArguments
...
<Notice>: exited due to exit(78)
...
<Notice>: cannot spawn: service is in penalty box
Then this cannot spawn spams a lot in launchd.log
Also I noticed one thing with KeepAlive agents. After renaming to Xcode14.2.app I can run sudo launchctl procinfo $pid and see that program path is new, but responsible path is still old.
I've tried to fight it by calling unregister() async and then register(), but it doesn't help at all. The behavior persists even if I uninstall the app, clean up manually by launchctl bootout and install again! Reboot doesn't help also. Crazy.
The only solution I see is to rollback to Program/ProgramArguments. In case the bundle path somehow changes, my script was doing launchctl bootout, sed plists with new paths, launchctl bootstrap.
Is it a bug? or some sort of misunderstanding from my side?