From 217cb5f76d75a6a3c77dfd24dfc84cb53626fa9c Mon Sep 17 00:00:00 2001 From: swapnil <78632212+swapnilpaliwal-sd@users.noreply.github.com> Date: Thu, 17 Sep 2026 23:08:53 -0700 Subject: [PATCH] fix: pin tree-sitter-java to the version tree-sitter-groovy pins, so it stays deduped tree-sitter-groovy depends on tree-sitter-java@0.23.4 exactly while the parser asked for ^0.21.0. Two versions npm cannot reconcile, so it nests a second copy under tree-sitter-groovy, and the nested copy's gyp config resolves node-addon-api by a relative path whose ../ count is wrong once nested. It cannot build even with a full toolchain. That is invisible wherever a prebuilt binary exists, because nothing compiles. On linux-arm64 the 0.21.x tree-sitter generation ships no prebuilt core, so the build runs, hits the nested copy and fails outright. Pinning to the same version leaves one hoisted copy. Measured on a clean arm64 VM: before, npm install failed with a toolchain installed; after, it succeeds and the parser produces 39 csv files and 48128 rows on a real Java project, matching macOS exactly. The IR is byte for byte identical to 0.21.0 on real Java and Python projects, so the grammar change is behaviour neutral. A caret range is not enough: ^0.23.4 resolves to 0.23.5 and nests again. The two have to name the same version, which is what the new check in package-contents-test.sh asserts. Verified it fails on the old value. This does NOT make linux-arm64 installable without a compiler. No 0.21.x core ships an arm64 prebuild, and no published tree-sitter-java or tree-sitter-groovy accepts a core above 0.21.x, so there is no version set that reaches one. arm64 still needs build-essential; this only removes the failure that a toolchain could not fix. Refs #901 --- graph/test/tools/package-contents-test.sh | 16 ++++++++++++++++ package.json | 2 +- parser/package.json | 4 ++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/graph/test/tools/package-contents-test.sh b/graph/test/tools/package-contents-test.sh index 82b603fe..13c580ac 100755 --- a/graph/test/tools/package-contents-test.sh +++ b/graph/test/tools/package-contents-test.sh @@ -36,6 +36,22 @@ const deps=j.dependencies||{}, pdeps=JSON.parse(fs.readFileSync(root+"/parser/pa Object.keys(deps).length ? ok("runtime dependencies are declared") : bad("package.json declares no runtime dependencies"); for(const k of Object.keys(pdeps)) deps[k] ? ok("dependency hoisted: "+k) : bad("runtime dependency not hoisted from the parser workspace: "+k); +// ---- the native grammar must not be duplicated ---- +// tree-sitter-groovy pins tree-sitter-java to an exact version. Asking for a different one +// leaves npm two versions to satisfy and it nests a second copy, whose gyp config resolves +// node-addon-api by a relative path that is wrong once nested -- so it cannot build even +// with a full toolchain, and linux-arm64, which has no prebuilt core and must build, fails +// outright. A caret range is not enough: ^0.23.4 resolves to 0.23.5 and nests again. The two +// have to name the SAME version. See #901. +try{ + const groovy=JSON.parse(fs.readFileSync(root+"/node_modules/tree-sitter-groovy/package.json","utf8")); + const want=(groovy.dependencies||{})["tree-sitter-java"]; + const have=(JSON.parse(fs.readFileSync(root+"/parser/package.json","utf8")).dependencies||{})["tree-sitter-java"]; + if(!want) ok("tree-sitter-groovy no longer depends on tree-sitter-java"); + else if(have===want) ok("tree-sitter-java matches the version tree-sitter-groovy pins ("+want+"), so it stays deduped"); + else bad("tree-sitter-java is "+have+" but tree-sitter-groovy pins "+want+"; npm will nest a second copy that cannot build (#901)"); +}catch(e){ console.log(" skip tree-sitter-groovy not installed; run npm install to assert the pin"); } + // ---- what the tarball would contain ---- let files; try{ diff --git a/package.json b/package.json index 500d357b..a6c2dda7 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "tree-sitter": "^0.21.1", "tree-sitter-c-sharp": "0.23.1", "tree-sitter-groovy": "^0.1.2", - "tree-sitter-java": "^0.21.0", + "tree-sitter-java": "0.23.4", "tree-sitter-python": "^0.21.0", "typescript": "^6.0.0", "yaml": "^2.8.2" diff --git a/parser/package.json b/parser/package.json index a7a5dedf..7c28c154 100644 --- a/parser/package.json +++ b/parser/package.json @@ -1,7 +1,7 @@ { "name": "@axiomcode/parser", "version": "0.1.0", - "description": "AxiomCode Parser \u2014 extracts Java/Python/TypeScript/Gradle/XML/YAML/Properties facts from a codebase.", + "description": "AxiomCode Parser — extracts Java/Python/TypeScript/Gradle/XML/YAML/Properties facts from a codebase.", "main": "dist/extract.js", "types": "dist/extract.d.ts", "scripts": { @@ -20,7 +20,7 @@ "tree-sitter": "^0.21.1", "tree-sitter-c-sharp": "0.23.1", "tree-sitter-groovy": "^0.1.2", - "tree-sitter-java": "^0.21.0", + "tree-sitter-java": "0.23.4", "tree-sitter-python": "^0.21.0", "typescript": "^6.0.0", "yaml": "^2.8.2"