Skip to content

[Bug] nanocoder daemon install can install an auto-start that will never boot in an untrusted project #1338

Description

@addyCooks

Description

Follow-up to #1259 (raised by @will-lamerton in review and by nc-review).

Since #1259, nanocoder daemon start refuses to boot with exit code 1 unless the project root is in preferences.trustedDirectories. nanocoder daemon install was not updated to match: it writes a service definition whose command is nanocoder daemon start, with restart-on-failure set, and reports only Auto-start installed for <root>. (source/daemon/install.ts:268, 297, 332).

If a user installs auto-start before they have ever run nanocoder interactively in that project, the service manager starts a daemon that fails the trust gate immediately, then retries on its restart policy forever. Nothing tells the user why, and install reported success.

Affected on all three platforms:

  • systemd user unit: Restart=on-failure, RestartSec=5
  • launchd LaunchAgent: KeepAlive: true
  • Windows Task Scheduler: restart-on-failure

Steps to Reproduce

  1. Clone any repo you have never opened with nanocoder, so the path is not in trustedDirectories.
  2. Run nanocoder daemon install in it.
  3. Observe Auto-start installed for <root>.
  4. Start the service (or log in again) and check the service manager's state.

Expected Behavior

daemon install tells the user when the project root is not trusted yet, and how to fix it: run nanocoder there once and accept the disclaimer, or pass --trust-directory.

Actual Behavior

install reports plain success. The installed service fails at every start with exit 1 and is restarted indefinitely.

Proposed Fix

  1. In install, check trust for opts.projectRoot via isDirectoryTrusted from @/config/preferences.
  2. When untrusted, keep installing but add a clear warning to the result message naming both remedies.
  3. Cover it in source/daemon/install.spec.ts, trusted and untrusted.

nc-review also floated writing Environment=NANOCODER_TRUST_DIRECTORY=1 into the generated unit. I would not do that: it silently grants exactly the trust the gate exists to require, and it would be invisible in the CLI output. Happy to go that way if maintainers prefer.

Additional Context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions