SMJobBless failed with CFErrorDomainLaunchd Code 9

4.4k views Asked by At

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 :-(

2

There are 2 answers

3
andrey.s On BEST ANSWER

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:

1
akim On

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