Skip to content

fix(cli): keep the existing binary under install --skip-binary - #2990

Open
DeusData wants to merge 1 commit into
mainfrom
fix/install-skip-binary-respected
Open

DeusData wants to merge 1 commit into
mainfrom
fix/install-skip-binary-respected

Conversation

@DeusData

Copy link
Copy Markdown
Owner

What

codebase-memory-mcp install --skip-binary --yes printed "Skipping binary placement (--skip-binary); configuring agents only." and then, when a different binary already sat at the install target, asked "A different binary already exists at: ... Replace it with the binary you ran install from?". --yes answered that prompt, so the file the flag promised to leave alone was replaced.

The same happened when install infers an externally managed binary (mise, Homebrew, nix, asdf, cargo; #1566 / #2722): it says "Leaving it and your PATH untouched; configuring agents only." and then replaced an older copy in ~/.local/bin the same way. That path matters in practice: when update refuses to touch a managed binary, it tells the user to run install --skip-binary.

On macOS there was a second way in: an existing target was always re-signed and republished (sign_binary = do_copy || target_exists), even under --skip-binary.

Why

#1566 (0e89ef8) gated the copy decision (do_copy) on !skip_binary, but the "different binary" prompt further down can set do_copy = true again, and the macOS signing step keys on target_exists alone. Both now respect skip_binary (explicit, or inferred for a managed binary). A --skip-binary install that resets no index now publishes nothing, which is what the activation-scope change (013e1f7) already assumed when it stopped quiescing sessions for that case.

Changes

  • src/cli/cli.c: skip the replace prompt when skip_binary is set, and skip the macOS re-sign/republish of an existing target in the same case. --force-binary still places a copy as before.

  • tests/test_cli.c (cli suite), two tests with a fake HOME whose ~/.local/bin/codebase-memory-mcp already holds a different file:

    • cli_install_skip_binary_keeps_a_different_existing_binary: install --skip-binary --skip-config --yes
    • cli_install_managed_binary_keeps_a_different_existing_binary_issue2722: mise-shaped running-binary path, install --skip-config --yes

    Each asserts exit code 0, the target byte-identical, the same file (inode unchanged; a republish renames a new file into place even when the bytes match), and nothing staged beside it.

Verification (macOS arm64, ASan/UBSan test-runner)

  • RED before the fix, 3 of 3 runs: both tests print the replace prompt, y (auto), Installed binary -> ..., and fail on byte identity.
  • With only the prompt guarded, both still fail on macOS. The target gets re-signed and republished as a copy of itself (new inode), which is why the signing step is gated too.
  • GREEN with both guards. RED again with both guards reverted.
  • On the final tree (rebased on main 1ec2f26): cli, activation_transaction, agent_clients and agent_profiles give 488 passed, 1 skipped (Windows-only), 1 failed. The failure is cli_vscode_only_installs_copilot_durable_context, and it fails the same way on an unmodified main build on that machine: the test expects a "VS Code-only" host, and that machine has a Copilot CLI on PATH. It does not touch the code changed here.
  • clang-format-20 (the CI version) and cppcheck 2.20 are clean on src/cli/cli.c, and the memory-core linter passes.

Other placement paths checked

  • update has no --skip-binary. It refuses outright for an externally managed binary, and release builds hand off to the install script.
  • install.sh / install.ps1 call install -y --force --dir=..., so they are unaffected.
  • scripts/smoke-test.sh runs install --skip-binary ... -y against a HOME whose ~/.local/bin holds a byte-identical cp of the binary. Before this fix those runs re-copied that file. Now they leave it alone, and no smoke assertion depends on the copy.

`install --skip-binary --yes` announced "Skipping binary placement" and
then replaced a different binary already at the install target: the
"A different binary already exists ... Replace it?" prompt set
do_copy = true again after #1566 had gated do_copy on !skip_binary, and
--yes answered that prompt. An externally managed binary (#1566/#2722),
for which install promises to leave the binary and PATH untouched, took
the same path. On macOS an existing target was also re-signed and
republished under either flag.

Skip the replace prompt and the macOS re-sign of an existing target
whenever skip_binary is set (explicit or inferred), so a --skip-binary
install that resets no index publishes nothing.

Tests (cli suite), fake HOME whose ~/.local/bin already holds a
different binary; each asserts the target byte-identical, the same file
(inode unchanged) and nothing staged beside it:
- cli_install_skip_binary_keeps_a_different_existing_binary
- cli_install_managed_binary_keeps_a_different_existing_binary_issue2722

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>

This branch has not been deployed

No deployments
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