Skip to content

Skill installer: find app-bundle/symlinked layouts, no build path in error - #3861

Merged
mstomar125 merged 2 commits into
mainfrom
fix/3831-skill-installer-error
Oct 20, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
fix/3831-skill-installer-error

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Refs #3831

Changes

  • compiled_installer_beside tries the exe dir, then the canonicalized exe dir (symlinked CLI); resources from skill/ or, in Contents/MacOS, ../Resources/resources/skill.
  • Not-found error lists the searched directories and says to reinstall / run the app once. The CARGO_MANIFEST_DIR path and build:skill hint appear only in debug builds.

Not done

  • Optional criterion: making the ~/.nodespace/bin staging copy find the installer (copy sidecar + skill/). The staged binary's own lookup is unchanged, so it still fails from there. Issue stays open.

Testing

  • cargo test -p nodespace-cli installer: 15 passed (new: app-bundle, symlink, message tests).
  • Mutation: disabling the canonical-dir and bundle lookups fails both layout tests.
  • cargo clippy -p nodespace-cli --all-targets -- -D warnings and cargo fmt --check clean.

🤖 Generated with Claude Code

@mstomar125 mstomar125 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE WITH NITS

Independent review of #3861 (Refs #3831). I ran cargo test -p nodespace-cli --lib commands::skill::tests::compiled, and all 5 pass. Findings below.

Acceptance criteria

  • Not-found message lists the searched directories and has no build-time path in release: met. skill.rs:1297-1306 only passes the hint when cfg!(debug_assertions).
  • Canonicalized exe dir and app-bundle layout accepted: met (exe_dirs, resource_root_candidates).
  • Tests for message, bundle and symlink: met.
  • Optional ~/.nodespace/bin copy: NOT done. See finding 1.

Layouts and safety (verified by reading the code and tests)

  • A Homebrew or /usr/local/bin symlink to a real binary resolves. The plain sibling dir is tried first, then the canonical dir. current_exe() is kernel-supplied and absolute on macOS, so relative argv0 and path traversal do not apply.
  • A canonicalize failure is handled: .ok().and_then(...) falls back to the plain dir only.
  • The sidecar that gets executed and the resource root come from the same trust domain as the running nodespace binary itself (its own dir or its real dir, or ../Resources/resources/skill within the same .app). The bundle branch only fires when the dir is literally Contents/MacOS. It adds no new directory an attacker could choose. A world-writable exe dir is a pre-existing exposure. The code never searches PATH, cwd, or any other directory.
  • Installer::Compiled runs binary with resource_root as an argument (skill.rs:1326-1333). That is unchanged.

Findings

  1. (non-blocking) skill.rs:1297-1306: the ~/.nodespace/bin/nodespace staging copy still cannot find the installer, because it has no sidecar beside it. A canonical dir equals itself for a copy, and a copy is not a symlink. That scenario is the second bullet of the issue's "What happens". The message now says clearly what to do, but the optional AC is open, so do not let #3831 auto-close on it. The PR says Refs, which is correct. Please file a follow-up or note it in the PR.
  2. (non-blocking) skill.rs:1294-1306: "directories searched" lists only the exe dirs. The bundle Resources/resources/skill root and the skill/ subdirs probed are not named. The message does say "and its skill/ resources in: {dirs}", so it is not wrong, but for a bundle the listed dir (Contents/MacOS) hides the second location. Consider listing the roots from resource_root_candidates.
  3. (non-blocking, test gap) The debug-only gating of the CARGO_MANIFEST_DIR hint (skill.rs:~1303) is untested. Mutation: I changed cfg!(debug_assertions) to true, so the release build would print the CI path again. All tests still passed (the only failure in that run was my other mutation). The unit test covers only the pure helper with None and Some. A cheap guard is a test that asserts the caller passes None when !cfg!(debug_assertions), or extract fn source_hint(path) -> Option<&Path> and test it under #[cfg(not(debug_assertions))]. This is the PR's headline guarantee, so it deserves a regression test.
  4. (non-blocking) Mutation of the other logic: disabling the canonical-dir push is killed by the symlink test. I did not find a surviving mutant in the bundle logic. Removing the bundle branch would fail the bundle test.
  5. (non-blocking nit) Windows: canonicalize() returns \\?\ verbatim paths, so dirs.contains will not dedupe and the message shows the \\?\ form. Harmless, since the bundle layout is macOS-only.
  6. (non-blocking nit) cfg!(debug_assertions) is the right switch. Release profile (Cargo.toml:77) does not enable debug-assertions, and no feature is involved. env!("CARGO_MANIFEST_DIR") is still compiled into the binary as the path.exists() probe, but is never printed in release. Note that in a release build on a dev machine where that path exists, the script is still executed. That behaviour is unchanged and the issue allowed "or when that path exists", so this is stricter than the issue. Fine.

No blocking issues.

mstomar125 and others added 2 commits October 20, 2026 16:32
…; list searched dirs in not-found error

compiled_installer_beside now tries the exe directory then its canonicalized
directory, and resolves resources from skill/ or, inside Contents/MacOS,
../Resources/resources/skill. The not-found message names the searched
directories and omits the build-time CARGO_MANIFEST_DIR path outside debug builds.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… list bundle resource roots searched

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mstomar125
mstomar125 force-pushed the fix/3831-skill-installer-error branch from 5f2c335 to 659ddb2 Compare October 20, 2026 14:32
@mstomar125
mstomar125 merged commit 3fc8ceb into main Oct 20, 2026
@mstomar125
mstomar125 deleted the fix/3831-skill-installer-error branch October 20, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant