10

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

akim
  • 8,255
  • 3
  • 44
  • 60
andrey.s
  • 789
  • 10
  • 28
  • How are you codesigning your helper tool? – l'L'l Aug 27 '15 at 21:29
  • @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. – andrey.s Aug 27 '15 at 22:15
  • 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. – Kristopher Johnson Aug 23 '18 at 20:06

2 Answers2

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

akim
  • 8,255
  • 3
  • 44
  • 60
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:

andrey.s
  • 789
  • 10
  • 28
  • "There is seems to be no way to remove a service from that disabled.plist file." false sttatement: sudo launchctl enable system/com.example.service – GeekUser Nov 06 '19 at 11:32
  • 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. – andrey.s Nov 08 '19 at 00:53