Skip to content

fix(installer): rewrite staging path in venv files after mv to target#3

Merged
vladolaru merged 1 commit into
vladolaru:mainfrom
georgeolaru:fix/installer-relocate-shebangs-after-mv
May 13, 2026
Merged

fix(installer): rewrite staging path in venv files after mv to target#3
vladolaru merged 1 commit into
vladolaru:mainfrom
georgeolaru:fix/installer-relocate-shebangs-after-mv

Conversation

@georgeolaru

Copy link
Copy Markdown
Contributor

Summary

  • Fixes a broken `cc-codex-bridge` command after install — every script under `bin/` had a shebang pointing at the staging dir, which no longer existed after `mv` to `TARGET_DIR`.
  • Adds a post-relocation `--help` smoke test so future regressions fail at install time, not on first invocation.

Problem

`install.sh.in` builds the venv at `${INSTALL_ROOT}/versions/.install-${INSTALL_TAG}-$$` (`STAGE_DIR`), pip-installs the wheel into it, then `mv`s the directory to `${TARGET_DIR}`. pip's wheel installer bakes the staging python path into entry-point shebangs (e.g. `${STAGE_DIR}/bin/python`). After the `mv`, every script in `bin/` has a shebang pointing at a path that no longer exists.

First invocation of `cc-codex-bridge` fails with:

```
bad interpreter: .../versions/.install-vX.Y.Z-NNNN/bin/python: no such file or directory
```

(Reproduced on a fresh `curl … | bash` install of v1.5.1 on macOS / Python 3.12 from Homebrew. The pre-`mv` `STAGE_DIR/bin/cc-codex-bridge --help` and `doctor` smoke tests pass because the staging path is still real at that point.)

Fix

After `mv`, rewrite the staging path to the final target path across the venv files that embed it:

  • `bin/*` script shebangs (`pip`, `pip3`, `pip3.12`, `cc-codex-bridge`)
  • `pyvenv.cfg` (the `command` field records the venv's creation path)
  • `activate`, `activate.csh`, `activate.fish` (each embeds `VIRTUAL_ENV`)

The rewrite uses the venv's own `bin/python`, which is a symlink chain to the system python and survives the `mv` intact (the symlink target is absolute).

A new post-relocation `--help` smoke test catches any future regression at install time rather than on first invocation.

Test plan

  • Manually verified against the actual broken v1.5.1 install on disk: extracting the rewrite snippet and running it rewrote `pip3.12`, `cc-codex-bridge`, `pip3`, `activate.fish`, `pip`, `activate`, `activate.csh`, `pyvenv.cfg`. `cc-codex-bridge --version` then succeeded (was failing with `bad interpreter` before).
  • End-to-end install via `install.sh` requires a release wheelhouse, which the standard release workflow will produce. The new `--help` smoke test will catch a regression at install time if anything slips through.

`install.sh.in` builds the venv at `${INSTALL_ROOT}/versions/.install-${INSTALL_TAG}-$$`
(STAGE_DIR), pip-installs the wheel into it, then `mv`s the directory
to `${TARGET_DIR}`.  pip's wheel installer bakes the staging python path
into entry-point shebangs (e.g. `${STAGE_DIR}/bin/python`), so after the
`mv` every script under `bin/` has a shebang pointing at a path that no
longer exists.  Result: the next `cc-codex-bridge` invocation fails with

    bad interpreter: .../versions/.install-vX.Y.Z-NNNN/bin/python:
    no such file or directory

The staging path is now rewritten to the final target path across the
venv files that embed it — `bin/*` shebangs, `pyvenv.cfg`, and the
`activate` scripts — using the venv's own `bin/python` (which is a
symlink chain to the system python and survives the `mv` intact).  A
post-relocation `--help` smoke test guards against future regressions.

Verified against a real broken v1.5.1 install on disk: rewriting
`pip3.12 cc-codex-bridge pip3 activate.fish pip activate activate.csh
pyvenv.cfg` makes `cc-codex-bridge --version` succeed again.
@vladolaru

Copy link
Copy Markdown
Owner

@copilot resolve the merge conflicts in this pull request

@vladolaru
vladolaru merged commit 672a441 into vladolaru:main May 13, 2026
1 check passed
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.

2 participants