Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SMJobBless failed with CFErrorDomainLaunchd Code 9

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. People say(on some support forum 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 :-(

like image 365
andrey.s Avatar asked Aug 25 '15 10:08

andrey.s


2 Answers

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:

  • http://comments.gmane.org/gmane.comp.sysutils.launchd.devel/117
  • http://launchd.info
  • A great app to manage launchd tasks: http://www.soma-zone.com/LaunchControl/
  • man launchctl
like image 129
andrey.s Avatar answered Sep 22 '22 09:09

andrey.s


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

like image 40
akim Avatar answered Sep 23 '22 09:09

akim