Skip to content

fix(scripts): resolve argv[1] before the entry-module check (macOS prepush_focus red) - #49

Closed
Zelys-DFKH wants to merge 2 commits into
mainfrom
macfix2
Closed

Zelys-DFKH wants to merge 2 commits into
mainfrom
macfix2

Conversation

@Zelys-DFKH

Copy link
Copy Markdown
Collaborator

Draft to run test-macos. The pre-push focus tests failed only on macOS because four scripts compared import.meta.url with the unresolved argv[1]; macOS temp folders are symlinks, so the CLI branch was skipped silently. See the commit message for the evidence. Close without merging.

…inked folder still runs the CLI

The pre-push focus tests failed only on macOS: the focus list came back empty and the note read "recorded commit  is not an ancestor" with a blank sha. The cause is not bash 3.2. prepush-failed.mjs, prepush-tree-readers.mjs, test-durations.mjs and lock-commit-subject.mjs decided they were the entry module with import.meta.url === pathToFileURL(process.argv[1]).href. Node resolves the entry module's symlinks for import.meta.url but leaves argv[1] as written, and macOS temp folders sit behind a symlink (/var and /tmp point into /private), so the comparison was false, the CLI branch was skipped, and the script exited 0 with no output. `record` wrote no store, `read` printed nothing, and focus_decide took an empty record as a blank sha. The same bug let the commit-msg lock check pass any subject when started through a symlinked path.

All four now compare pathToFileURL(realpathSync(process.argv[1])).

Tests: prepush_focus.test.ts now reaches its sandbox through a directory junction/symlink, scripts_main_through_symlink.test.ts runs each script through a link, and guards/entry_module_check_resolves_symlinks.test.ts rejects a bare comparison. Against the old scripts on Windows the focus tests failed with the CI messages ("expected [] to deeply equal [ 'src/a.ts', ... ]" and "win leg full: recorded commit  is not an ancestor of this push"); with the fix they pass.
@Zelys-DFKH

Copy link
Copy Markdown
Collaborator Author

Closing without merging; branch macfix2 is left for landing.

@Zelys-DFKH Zelys-DFKH closed this Oct 17, 2026
…h a resolve fallback

The first fix called realpathSync(process.argv[1]) with no fallback, so an entry path that does not exist (node -e "import(...)" foo) crashed at import, and in lock-commit-subject that crash would fail the commit-msg gate. scripts/is-main-module.mjs now resolves both sides with plain realpathSync (the ESM loader's own form, which matches import.meta.url on Windows with a lowercase drive letter where .native does not) and falls back to path.resolve, so a missing entry is a plain "not main".

Every entry check under scripts/ uses it: the four prepush and lock scripts, the five scripts that carried a private realOrResolved copy plus parser-fingerprint, the two that matched on file name, and the four eval-*.ts scripts that compared path.resolve(argv[1]), which does not follow symlinks (tsx reports the real path in import.meta.url, checked by running one through a junction). verify-native-dist.mjs keeps its own copy because it ships in the npm package and is copied alone by its tests.

Tests: scripts_main_through_symlink.test.ts now asserts each script's real output through a link (stderr and stdout, not only the exit status), imports each script with a nonexistent entry path, and unit-tests the helper. The guard reads the whole file with comments stripped, covers .mjs, .js, .cjs and .ts, and requires the helper wherever argv[1] sits beside import.meta.url or __filename. The junction tests skip, and say so, on a machine that cannot create one. Red runs: the guard failed on eval-gate.ts and prepush-failed.mjs with the old comparisons put back, and six tests failed with ENOENT on the helper without its fallback.
@Zelys-DFKH Zelys-DFKH reopened this Oct 17, 2026
@Zelys-DFKH

Copy link
Copy Markdown
Collaborator Author

Green on all jobs; closing unmerged, branch macfix2 left for landing.

@Zelys-DFKH Zelys-DFKH closed this Oct 17, 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