Skip to content

fix(cli): cc-connect upgrade resolves symlinked launch path#3

Open
Nemoljy wants to merge 2 commits into
Minara-AI:mainfrom
Nemoljy:fix/upgrade-resolve-symlinked-launch
Open

fix(cli): cc-connect upgrade resolves symlinked launch path#3
Nemoljy wants to merge 2 commits into
Minara-AI:mainfrom
Nemoljy:fix/upgrade-resolve-symlinked-launch

Conversation

@Nemoljy
Copy link
Copy Markdown

@Nemoljy Nemoljy commented May 16, 2026

Summary

  • install.sh symlinks ~/.local/bin/cc-connect<clone>/target/release/cc-connect. On macOS, std::env::current_exe() returns the launch path verbatim (the symlink), not the canonical target — so cc-connect upgrade's locate_install_repo walked up from ~/.local/bin/, never found a .git ancestor, and bailed for every source install launched the standard way. Canonicalize before walking up.
  • Refactor the walk into a testable locate_install_repo_from(exe: &Path) (pub(crate)) and have cc-connect doctor reuse it so this footgun surfaces in doctor — until now it was invisible until the user actually ran cc-connect upgrade.

Closes #2.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --tests -- -D warnings
  • cargo test --workspace — including two new unit tests in crates/cc-connect/src/lifecycle.rs::tests:
    • locate_install_repo_from_resolves_symlinked_launch — positive: builds a tempdir checkout + ~/.local/bin-style symlink, asserts the canonical checkout is returned.
    • locate_install_repo_from_errors_outside_checkout — negative: preserves the original actionable "re-run from inside the clone" error.
  • Manual: ./target/debug/cc-connect doctor (run from inside the repo) now reports [OK] cc-connect upgrade target: /Users/.../cc-connect between cc-connect binary and identity.key. Pre-existing checks unchanged.

Domain & docs

None of the toggles apply — no new domain term, no architectural decision, no wire-format / threat-surface change.

Notes for the reviewer

Two commits, split deliberately so the fix can land without the doctor enhancement if you'd prefer to gate that separately:

  1. fix(cli): cc-connect upgrade resolves symlinked launch path — the canonicalize fix + pub(crate) refactor + tests.
  2. feat(cli): doctor surfaces cc-connect upgrade target repo — adds the matching cc-connect doctor line that would have caught this in doctor instead of in upgrade.

Linux wasn't independently verified — /proc/self/exe is generally canonical there, so the bug is likely macOS-only in practice. canonicalize is harmless on Linux (no-op on an already-canonical path).

Nemoljy and others added 2 commits May 17, 2026 03:39
`install.sh` symlinks the built cc-connect binary into
`~/.local/bin/`, and on macOS `std::env::current_exe()` returns the
launch path verbatim (the symlink itself), not the canonical target.
`locate_install_repo` therefore walked up from `~/.local/bin/` ->
`~/.local/` -> `~/` -> `/`, found no `.git` ancestor, and bailed —
breaking `cc-connect upgrade` for every source install where the
user launched via the symlink.

Canonicalize the exe before walking up. Refactor the walk into a
testable `locate_install_repo_from(exe: &Path)` (pub(crate) so the
forthcoming `cc-connect doctor` upgrade-target check can reuse the
same logic without re-entering `current_exe`).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The "upgrade fails from a symlinked launch" footgun fixed in the
previous commit was invisible until the user actually ran
`cc-connect upgrade`. Add an `upgrade target` line to
`cc-connect doctor` that runs the same lookup against the running
binary's canonical path, so the answer is visible at the same place
users already look when something feels off.

- Source install (`~/.local/bin/cc-connect` -> `<clone>/target/...`):
    [OK]  cc-connect upgrade target: /Users/.../cc-connect
- Binary install (bootstrap.sh into `~/.cc-connect/bin/`):
    [--]  no git checkout above this binary — `cc-connect upgrade`
          won't work. If you installed via bootstrap.sh, re-run it
          to upgrade; otherwise `git pull && ./install.sh` from
          inside the clone.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

[bug]: cc-connect upgrade fails when launched via the ~/.local/bin symlink

1 participant