Skip to content

[codex] harden worktree setup scripts#4450

Merged
ScriptedAlchemy merged 2 commits intomainfrom
codex/worktree-safe-scripts
Feb 15, 2026
Merged

[codex] harden worktree setup scripts#4450
ScriptedAlchemy merged 2 commits intomainfrom
codex/worktree-safe-scripts

Conversation

@ScriptedAlchemy
Copy link
Copy Markdown
Member

Summary

This PR hardens the worktree-safe wrapper scripts used by local setup and Nx execution.

Problem

Worktree commands were failing in two practical cases:

  1. pnpm run nx:safe -- run <project>:<target> forwarded a literal -- into nx, so Nx treated it as argument separator and dropped the command payload. This resulted in errors like "Not enough non-option arguments".
  2. Worktree setup could intermittently fail during pnpm install with transient virtual-store ENOENT errors (for example missing node_modules/.pnpm/.../package.json during first install), causing worktree initialization to abort.

Root Cause

  • scripts/nx-worktree.sh forwarded raw "$@" directly to pnpm exec nx and did not normalize a leading -- token.
  • scripts/codex-setup.sh also passed raw install arguments and had no targeted recovery path for transient pnpm virtual-store ENOENT failures.

Fix

  • Updated scripts/nx-worktree.sh to normalize forwarded args:
    • strips a leading -- when present
    • validates arguments after normalization
    • forwards normalized args to Nx in both worktree and non-worktree modes
  • Updated scripts/codex-setup.sh to:
    • normalize leading -- for pnpm run setup:codex -- ... usage
    • run installs via a wrapper that captures output and retries once only when failure matches the known node_modules/.pnpm/.../package.json ENOENT signature
    • preserve existing worktree behavior (NX_DAEMON=false + graph priming)

User Impact

  • Worktree-safe Nx execution now behaves consistently for both invocation styles:
    • pnpm run nx:safe -- run ...
    • pnpm run nx:safe run ...
  • Worktree setup is more resilient to transient pnpm virtual-store race/corruption failures and is less likely to fail at initialization time.

Validation

Executed locally:

  • bash -n scripts/codex-setup.sh scripts/nx-worktree.sh
  • ./scripts/codex-setup.sh -- --frozen-lockfile
  • pnpm run nx:safe -- run runtime-core:build --help
  • pnpm run nx:safe run runtime-core:build --help
  • npx nx format:check

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 15, 2026

⚠️ No Changeset found

Latest commit: db047ac

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link
Copy Markdown

netlify bot commented Feb 15, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit db047ac
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/69924ed2128eb300081c2214
😎 Deploy Preview https://deploy-preview-4450--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ScriptedAlchemy ScriptedAlchemy marked this pull request as ready for review February 15, 2026 22:24
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 15, 2026

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/devtools@4450

@module-federation/cli

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/cli@4450

create-module-federation

pnpm add https://pkg.pr.new/module-federation/core/create-module-federation@4450

@module-federation/data-prefetch

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/data-prefetch@4450

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/dts-plugin@4450

@module-federation/enhanced

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/enhanced@4450

@module-federation/error-codes

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/error-codes@4450

@module-federation/managers

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/managers@4450

@module-federation/manifest

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/manifest@4450

@module-federation/metro

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro@4450

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro-plugin-rnc-cli@4450

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro-plugin-rnef@4450

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/modern-js-v3@4450

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/retry-plugin@4450

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rsbuild-plugin@4450

@module-federation/rspack

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rspack@4450

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rspress-plugin@4450

@module-federation/runtime

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime@4450

@module-federation/runtime-core

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime-core@4450

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime-tools@4450

@module-federation/sdk

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/sdk@4450

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/third-party-dts-extractor@4450

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/treeshake-frontend@4450

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/treeshake-server@4450

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/webpack-bundler-runtime@4450

@module-federation/bridge-react

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-react@4450

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-react-webpack-plugin@4450

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-shared@4450

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-vue3@4450

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/inject-external-runtime-core-plugin@4450

commit: db047ac

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 15, 2026

Bundle Size Report

No bundle size changes detected.

Total dist: 6.87 MB (no change)
Total ESM gzip: 138.6 kB (no change)

@ScriptedAlchemy ScriptedAlchemy merged commit 7927967 into main Feb 15, 2026
25 checks passed
@ScriptedAlchemy ScriptedAlchemy deleted the codex/worktree-safe-scripts branch February 15, 2026 23:47
@2heal1 2heal1 mentioned this pull request Mar 5, 2026
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