Skip to content

fix(setup): use portable env-bash shebang in host scripts - #690

Merged
c-vigo merged 2 commits into
feature/625-nix-claude-migrationfrom
bugfix/687-portable-host-shebangs
Jun 24, 2026
Merged

c-vigo merged 2 commits into
feature/625-nix-claude-migrationfrom
bugfix/687-portable-host-shebangs

Conversation

@c-vigo

@c-vigo c-vigo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Three host-executed scripts hardcoded a non-portable #!/bin/bash shebang. On NixOS (and other hosts that do not provide /bin/bash), the kernel cannot resolve the interpreter, so the scripts fail to execute — which is why just test aborts on NixOS hosts. Switched all three to the portable #!/usr/bin/env bash form already used by scripts/init.sh, which resolves bash via PATH.

Root cause

A #!/bin/bash shebang requires bash to live at the absolute path /bin/bash. NixOS does not populate /bin with FHS binaries (only /bin/sh exists), so any host-side script with that shebang is not directly executable. #!/usr/bin/env bash defers interpreter lookup to PATH, working on both FHS and NixOS hosts.

Files changed (shebang only)

  • install.sh
  • assets/workspace/.devcontainer/scripts/initialize.sh
  • assets/workspace/.devcontainer/scripts/version-check.sh

The in-container script consistency sweep is intentionally out of scope (per the issue).

Tests

Added a reproducible portability test (TestHostScriptShebangPortability in tests/test_install_script.py) that parametrizes over the three host scripts and asserts each starts with #!/usr/bin/env bash. It is a pure content check (no container image needed). Confirmed RED before the fix (3 failures) and GREEN after (3 passed). The issue's original three failing tests are environment-specific (only reproduce on a NixOS host with no /bin/bash) and so are not reproducible in CI; this new test covers the regression deterministically.

Closes #687

@c-vigo
c-vigo merged commit a4082b9 into feature/625-nix-claude-migration Jun 24, 2026
10 checks passed
@c-vigo
c-vigo deleted the bugfix/687-portable-host-shebangs branch June 24, 2026 14:33
c-vigo added a commit that referenced this pull request Jun 24, 2026
…git-hook shebangs) (#694)

## Summary

Fixes the flaky `initialized_workspace` testinfra fixture that timed out
during
`uv sync`, cascading an `ERROR at setup` to every dependent test. Folds
in a
companion portability fix for the git hooks (same `#!/bin/bash`-on-NixOS
class as
#690), without which commits cannot run on a NixOS host.

Sub-issue of the #625 Nix migration epic; targets the epic branch
`feature/625-nix-claude-migration`.

## Changes

### `test(setup)` — init dep-sync timeout (Closes #692)
- The fixture allowed only **30s** for the `Workspace initialized
successfully`
  banner after `Syncing dependencies`. That window covers `just sync`
(`uv sync --all-extras`) downloading the test-project's heavy scientific
extras
(`numpy`, `scipy`, `pandas`, `matplotlib`, `jupyter`) with **no warm uv
cache**,
  so a cold/slow network times out mid-download.
- Raise the completed-stage timeout to a generous **300s** default,
overridable
  via `INIT_DEPS_SYNC_TIMEOUT` for fast-cache/CI tuning.

### `fix(setup)` — portable git-hook shebangs (Refs #690)
- `.githooks/{pre-commit,commit-msg,prepare-commit-msg}` hardcoded
`#!/bin/bash`.
Like the host scripts fixed in #690, these run on the host and fail on
NixOS
(no `/bin/bash`): `fatal: cannot exec '.githooks/pre-commit': No such
file or
  directory`. Switched to portable `#!/usr/bin/env bash`.

## Verification

- Python syntax + `INIT_DEPS_SYNC_TIMEOUT` env override resolve
correctly
  (verified via `uv run python`).
- Longest added line = 80 chars (< the 88 `line-length`), so `ruff` is
clean.
- pre-commit ran green for every hook that can execute on the host
(shellcheck,
bandit, agent-identity, branch-name, commit-msg validation,
sync-manifest).
- `ruff`/`ruff-format`/`typos` cannot execute on this NixOS host
(dynamically
linked binaries — the very limitation #625 addresses) and were skipped
locally
via pre-commit `SKIP`; **CI enforces them on this PR**. No `--no-verify`
used.

## Notes

The durable fix (warming the uv cache in the Nix-built image so `uv
sync` is
offline-fast) belongs to the #634/#635 image track and is out of scope
here.

Closes #692
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