Skip to content

fix(init-workspace): make post-scaffold dependency sync mode-aware and non-fatal - #1125

Merged
c-vigo merged 4 commits into
devfrom
bugfix/1118-nonfatal-sync
Jul 15, 2026
Merged

c-vigo merged 4 commits into
devfrom
bugfix/1118-nonfatal-sync

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

During a direnv-mode install.sh --force upgrade, after all scaffold files were written successfully, init-workspace.sh ran just sync (npm ci) inside the container; under set -euo pipefail a sync failure (observed: npm error Exit handler never called!) aborted the whole init and install.sh reported a misleading "Failed to initialize workspace". Two fixes, per the issue's two questions: the container-side sync is now skipped entirely in direnv/bare modes (the consumer's host nix/direnv shell owns dependency install; a container-side npm ci writes wrong-platform, wrong-owner artifacts into the bind-mounted workspace), and where it does run (devcontainer/both) a failure warns and continues so the exit status reflects the scaffold result. Observed on the vig-os/commit-action 1.2.1 upgrade (vig-os/commit-action#80).

Closes #1118

Type of Change

  • feat -- New feature
  • fix -- Bug fix
  • docs -- Documentation only
  • chore -- Maintenance task (deps, config, etc.)
  • refactor -- Code restructuring (no behavior change)
  • test -- Adding or updating tests
  • ci -- CI/CD pipeline changes
  • build -- Build system or dependency changes
  • revert -- Reverts a previous commit
  • style -- Code style (formatting, whitespace)

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

  • assets/init-workspace.sh (post-scaffold sync block): mode gate — direnv/bare skip the sync with an informational line; devcontainer/both run it as just sync || echo "Warning: …" >&2 (warn-and-continue, reusing the established non-fatal post-scaffold idiom). The existing [CHORE] Field-validate 0.4.0-rc4 in real consumer repos before finalize #859 "no sync recipe" warn-and-continue branch is preserved. Comment block updated to document both behaviors.
  • tests/bats/init-workspace.bats: _scaffold_synclog helper (a just stub that logs invocations and controls the sync exit code) + two regression tests: direnv mode never invokes just sync and prints the skip message; devcontainer mode with a failing sync recipe exits 0 with the warning (and asserts sync was actually attempted).

Changelog Entry

Fixed

  • Post-scaffold dependency sync is mode-aware and no longer aborts a successful upgrade (#1118)
    • In direnv and bare modes the container-side just sync is now skipped entirely: the consumer's host nix/direnv shell owns dependency install, and a container-side npm ci/uv sync would write wrong-platform, wrong-owner artifacts into the bind-mounted workspace. An informational line notes the skip.
    • In devcontainer/both modes the sync still runs but is non-fatal — a failure (e.g. npm error Exit handler never called!) now warns and continues instead of aborting init with a misleading "Failed to initialize workspace", since the scaffold itself is already complete.

Testing

  • Tests pass locally (just test)
  • Manual testing performed (describe below)

Manual Testing Details

  • TDD: both regression tests committed failing (RED — direnv mode still synced; failing sync aborted init), turned GREEN by the fix.
  • Full tests/bats/init-workspace.bats: 200 tests, 0 failures, exit 0 (implementation run + independent review run).
  • prek run --all-files: green.

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (edit docs/templates/, then run just docs)
  • I have updated CHANGELOG.md in the [Unreleased] section (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Part of the commit-action-deployment bug batch. The image-side root cause of npm error Exit handler never called! is out of scope here (this PR only removes its blast radius); worth a separate look if it recurs.

Refs: #1118

c-vigo added 3 commits July 15, 2026 15:37
Add regression tests for the post-scaffold `just sync` step: direnv mode
must skip the container-side sync entirely, and a failing sync in
devcontainer mode must warn-and-continue with init exiting 0.

Refs: #1118
…d non-fatal

Skip the container-side `just sync` entirely in direnv and bare modes, where
the consumer's host nix/direnv shell owns dependency install and a container
`npm ci`/`uv sync` would write wrong-platform, wrong-owner artifacts into the
bind-mounted workspace. In devcontainer and both modes the sync still runs but
warns and continues on failure instead of aborting init with a misleading
"Failed to initialize workspace" after an otherwise complete scaffold.

Refs: #1118
@c-vigo c-vigo self-assigned this Jul 15, 2026
@c-vigo
c-vigo merged commit e08bd59 into dev Jul 15, 2026
13 checks passed
@c-vigo
c-vigo deleted the bugfix/1118-nonfatal-sync branch July 15, 2026 14:38
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