Skip to content

Commit fdcf418

Browse files
roninjin10codexclaude
committed
🐛 fix(build-cli): canonicalize declaration packages with the native filesystem
Use native realpath for physical package identity so extended Windows drive paths do not enter the JavaScript root walker. Retain foreign-runtime refusal and add a Windows namespace regression. Windows CI run 35478107086 job 105990807739 died with `EISDIR: illegal operation on a directory, lstat D:` in the declaration preflight before any suite could run (nodejs/node#62446). Written by GPT-6 Astra; landed here after its run was cut off by a usage limit. Co-Authored-By: GPT-6 Astra <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent b024c34 commit fdcf418

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎packages/smithers/build/build-cli/src/internal/DeclarationDependencies.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ export const assertDeclarationDependencies = (
5959
try {
6060
const cli = findPackageJSON(dependency, import.meta.url)
6161
if (cli === undefined) throw new Error(`the CLI cannot locate ${dependency}`)
62-
expected = realpathSync(cli)
62+
// Self-resolution can return an extended Windows path. Node's
63+
// JavaScript realpath walker misreads its drive root on supported
64+
// releases; the native resolver preserves the physical-file check.
65+
expected = realpathSync.native(cli)
6366
let declared: string | undefined
6467
try {
6568
declared = findPackageJSON(dependency, pathToFileURL(file))
@@ -74,7 +77,7 @@ export const assertDeclarationDependencies = (
7477
if (options.bootstrap) continue
7578
throw new Error(`the declaration cannot locate ${dependency}`)
7679
}
77-
actual = realpathSync(declared)
80+
actual = realpathSync.native(declared)
7881
} catch (cause) {
7982
throw new PackageError(
8083
"declaration_dependency_unresolved",

‎packages/smithers/build/build-cli/test/EffectResolutionContract.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ describe("declaration dependency preflight", () => {
125125
expect(() => assertDeclarationDependencies([file], { bootstrap: false })).not.toThrow()
126126
})
127127

128+
it.runIf(process.platform === "win32")(
129+
"accepts the extended Windows spelling of a shared package declaration",
130+
() => {
131+
const manifest = findPackageJSON("@smthrs/targets", import.meta.url)!
132+
const file = Path.toNamespacedPath(Path.join(Path.dirname(manifest), "PACKAGE.ts"))
133+
expect(file.startsWith("\\\\?\\")).toBe(true)
134+
expect(() => assertDeclarationDependencies([file], { bootstrap: false })).not.toThrow()
135+
}
136+
)
137+
128138
it("refuses a foreign installation even when its metadata cannot be parsed", async () => {
129139
const directory = await fixture(false)
130140
await Fs.mkdir(Path.join(directory, "node_modules/effect"), { recursive: true })

0 commit comments

Comments
 (0)