Skip to content

daemon install fails to locate smctld when smctl is invoked via PATH (argv[0] is not absolute) #8

@GGGODLIN

Description

@GGGODLIN

Environment

  • smctl 0.1.8 (Homebrew, brew install leaperone/smctl/smctl)
  • MacBook Pro (M5 Pro), macOS 26 (Darwin 25.4.0)

Repro

$ sudo smctl daemon install
Error: Could not find smctld next to the current smctl executable.

Works fine with an absolute path:

$ sudo /opt/homebrew/bin/smctl daemon install
Installed smctld at /Library/LaunchDaemons/one.leaper.smctl.daemon.plist

Cause

DaemonInstall.currentSmctldPath() resolves the binary location from CommandLine.arguments[0]. When the command is found via PATH lookup, argv[0] is just smctl (not absolute), so the code falls back to cwd + "smctl" and looks for smctld in the current working directory.

Suggested fix

Resolve the real executable path with _NSGetExecutablePath (plus realpath to keep symlink behavior intentional) instead of trusting argv[0]. Note: with the Homebrew layout, resolving through the /opt/homebrew/bin/smctld symlink vs the Cellar path changes what the LaunchDaemon plist points at across upgrades — pointing at the symlink survives brew upgrade, the versioned Cellar path does not.

Happy to provide more details — found while setting up on a real machine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions