Skip to content

fix(devcontainer): fail loudly when tsx is unavailable in post-create - #31

Closed
c-vigo wants to merge 1 commit into
mainfrom
bugfix/30-postcreate-robustness
Closed

c-vigo wants to merge 1 commit into
mainfrom
bugfix/30-postcreate-robustness

Conversation

@c-vigo

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

Copy link
Copy Markdown
Contributor

Summary

.devcontainer/scripts/post-create.sh masked tsx install failures and could report a false success. The tsx step ran npm install -g tsx >/dev/null 2>&1 then printed tsx installed (<version>) using a probe that falls back to "" on failure. On the new hermetic Nix image the global npm prefix lands off-PATH (vig-os/devkit#728), so tsx was not actually available, yet the script printed tsx installed () and exited 0.

Changes

  • Stop swallowing the critical install. Drop >/dev/null 2>&1 and check the real exit status of npm install -g tsx; exit non-zero with a clear message if the install command itself fails.
  • Verify tsx is actually reachable after install. If command -v tsx succeeds, use it. Otherwise fall back to the pinned local devDependency via npx --no-install tsx (tsx is already in devDependencies). If neither is reachable, exit non-zero with an actionable message instead of reporting false success.
  • Document the apt/NodeSource fallback. Add a comment noting it is a Debian-only path, guarded by command -v node/npm (so it is skipped on the Nix image where Node is baked in). Full removal is tracked separately under the devcontainer bump ([TASK] Update devcontainer #29) and node-24 work ([TASK] Upgrade action to support Node.js 24 runtime #14/Migrate GitHub Action from Node.js 20 before runner deprecation #28) — not ripped out here.

Behaviour is unchanged on the current Debian image (ghcr.io/vig-os/devcontainer:0.1) where the global tsx is on PATH.

Verification

shellcheck -x and bash -n pass. Simulated all four code paths with stubbed tsx/npm/npx:

Scenario Result
tsx on PATH (current Debian image) prints version, exit 0
global install off-PATH, local devDep reachable via npx (Nix image) prints ... (via npx), exit 0
global install off-PATH AND npx cannot find tsx clear error, exit 1
npm install -g tsx itself fails clear error, exit 1

Context

Found while live-testing the vigOS devcontainer Nix migration. Related upstream image fixes: vig-os/devkit#727 (/usr/bin/env) and vig-os/devkit#728 (npm global prefix off-PATH).

Closes #30

The tsx step swallowed install output with `>/dev/null 2>&1` and probed
the version with a fallback to `""`, so a failed/off-PATH global install
still printed `tsx installed ()` and exited 0 (false success). On the
hermetic Nix image the global npm prefix lands off-PATH
(vig-os/devkit#728), masking that tsx was missing.

Drop the output swallow and check the install exit status; after install,
verify tsx is reachable on PATH, fall back to the pinned local
devDependency via `npx --no-install tsx`, and exit non-zero with a clear
message when neither is available. Also document that the apt/NodeSource
path is a guarded Debian-only fallback whose removal is tracked separately
(#29, #14/#28). Behaviour is unchanged on the current Debian image.

Refs: #30
@c-vigo

c-vigo commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by the devkit 1.1.0 migration (#32, commit 345ef2d), which removed the entire legacy apt/Debian .devcontainer/ scaffold — including post-create.sh, the file this PR patches. git ls-tree origin/main -- .devcontainer is now empty, which is why the PR shows as CONFLICTING: there is nothing left to rebase onto.

The masked-tsx-failure / apt-assumption root cause is fully resolved by that removal — exactly the fix #30 itself recommended ("remove the apt/NodeSource path once the devcontainer bump lands"). #30 is already closed as completed. Closing as obsolete.

@c-vigo c-vigo closed this Jul 14, 2026
@c-vigo
c-vigo deleted the bugfix/30-postcreate-robustness branch July 14, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant