SMJobBless failed with CFErrorDomainLaunchd Code 9
Asked Answered
H

2

11

Does anybody know what does that error code mean? I get SMJobBless error with this return code value.

Failed to bless helper: Error Domain=CFErrorDomainLaunchd Code=9 "The operation couldn’t be completed. (CFErrorDomainLaunchd error 9.)"

I googled, looked answers in blogs posts, in Apple Docs, here there and couldn't find the answer what is this and how to fix it. On some support forum people say that reinstalling OS X helped to them.

It has happened on my ongoing project already couple of weeks ago, and the only thing which helped me to fix it, was changing name of my helper tool. Now it happened again.

Same time my code is working on other computers, only my workstation is affected by this issue.

Update: After renaming, it works again. Now I have two helper tool bundle identifiers "banned" on my system :-(

Update 2: It happens on other computers as well :-(

Hibbard answered 25/8, 2015 at 10:53 Comment(3)
How are you codesigning your helper tool?Enamor
@l'L'l XCode does this. Host app and helper tool are signed with Developer ID. I use Qt framework in host app, and sign it separately in post build script.Hibbard
I have this issue on one computer. Has worked fine on dozens (maybe hundreds) of other machines. I wish we knew why it's not consistent.Amah
H
10

In my case the error

Failed to bless helper: Error Domain=CFErrorDomainLaunchd Code=9 "The operation couldn’t be completed. (CFErrorDomainLaunchd error 9.)"

meant that helper tool was added to permanent disabled services list here:

/private/var/db/com.apple.xpc.launchd/disabled.plist

I'm telling for Yosemite, older/younger OS versions may have them here(I haven't checked):

/var/db/launchd.db/com.apple.launchd.peruser.*user_id*/overrides.plist

After some reading of launchctl manual page, I found that "unload" subcommand's argument -w adds service to this plist file. I used this flag in my uninstaller script, which lead to inability of "blessing" tool at next time.

There is seems to be no way to remove a service from that disabled.plist file. On each reboot the file is being restored from launchd cache, and flushing cache seems to be not implemented yet. It is only possible to enable service forever so launchd won't stop it from launch.

Here is a couple of links which may be useful to someone who will run into similar issue:

Hibbard answered 1/9, 2015 at 13:54 Comment(3)
"There is seems to be no way to remove a service from that disabled.plist file." false sttatement: sudo launchctl enable system/com.example.serviceProphecy
This is true apparently after High Sierra (according to the answer below). The original question(and this answer) is relevant for Yosemite, which is explicitly stated.Hibbard
@Hibbard Any help on this question please, thanks! #77947972Botfly
G
11

With High Sierra (and probably before, but I don't know since when), there are several helping launchctl subcommands.

launchctl print-disabled system

will list the explicitly disable services. Be sure to check the false/true value.

To enable a disabled service

sudo launchctl enable system/com.example.service

Also, for the records, in /System/Library/Frameworks/ServiceManagement.framework/Versions/A/Headers/SMErrors.h one can read:

enum {
        kSMErrorInternalFailure = 2,
        kSMErrorInvalidSignature,
        kSMErrorAuthorizationFailure,
        kSMErrorToolNotValid,
        kSMErrorJobNotFound,
        kSMErrorServiceUnavailable,
        kSMErrorJobPlistNotFound,
        kSMErrorJobMustBeEnabled,
        kSMErrorInvalidPlist,
};

where the code 9 (kSMErrorJobMustBeEnabled) makes more sense than "The operation couldn’t be completed".

Gilbertson answered 28/5, 2018 at 11:26 Comment(1)
Hello, any idea about my question on similar lines (#77947972). Thanks in advanceBotfly
H
10

In my case the error

Failed to bless helper: Error Domain=CFErrorDomainLaunchd Code=9 "The operation couldn’t be completed. (CFErrorDomainLaunchd error 9.)"

meant that helper tool was added to permanent disabled services list here:

/private/var/db/com.apple.xpc.launchd/disabled.plist

I'm telling for Yosemite, older/younger OS versions may have them here(I haven't checked):

/var/db/launchd.db/com.apple.launchd.peruser.*user_id*/overrides.plist

After some reading of launchctl manual page, I found that "unload" subcommand's argument -w adds service to this plist file. I used this flag in my uninstaller script, which lead to inability of "blessing" tool at next time.

There is seems to be no way to remove a service from that disabled.plist file. On each reboot the file is being restored from launchd cache, and flushing cache seems to be not implemented yet. It is only possible to enable service forever so launchd won't stop it from launch.

Here is a couple of links which may be useful to someone who will run into similar issue:

Hibbard answered 1/9, 2015 at 13:54 Comment(3)
"There is seems to be no way to remove a service from that disabled.plist file." false sttatement: sudo launchctl enable system/com.example.serviceProphecy
This is true apparently after High Sierra (according to the answer below). The original question(and this answer) is relevant for Yosemite, which is explicitly stated.Hibbard
@Hibbard Any help on this question please, thanks! #77947972Botfly

© 2022 - 2024 — McMap. All rights reserved.