Skip to content

fix tree-sitter install on node 24#27

Open
qingliaowu wants to merge 2 commits into
salesforce:mainfrom
qingliaowu:fix/tree-sitter-node24-install
Open

fix tree-sitter install on node 24#27
qingliaowu wants to merge 2 commits into
salesforce:mainfrom
qingliaowu:fix/tree-sitter-node24-install

Conversation

@qingliaowu
Copy link
Copy Markdown

What

  • Adds a pnpm patch for tree-sitter@0.25.0 so its native binding builds with C++20 instead of C++17.
  • Records the patched dependency in the lockfile.
  • Adds a Node 24 install CI job to cover the reported install regression.

Why

Fixes #7.

Node 24 V8 headers require C++20, but tree-sitter@0.25.0 forces C++17 in binding.gyp. That makes pnpm install fail when the native binding compiles under Node 24.

How

The pnpm patch updates the upstream package build flags for Unix, macOS/Xcode, and Windows/MSVC to C++20. The new CI job runs pnpm install --frozen-lockfile on Node 24 so the install path is checked directly.

Test Plan

  • corepack pnpm install --frozen-lockfile on Node v24.10.0 without CXXFLAGS
  • corepack pnpm rebuild tree-sitter on Node v24.10.0 without CXXFLAGS
  • node --test packages/parser-tree-sitter/bindings/node/*_test.js
  • corepack pnpm --filter @agentscript/parser test
  • corepack pnpm exec prettier --check .github/workflows/ci.yml package.json pnpm-lock.yaml
  • corepack pnpm --filter @agentscript/parser-tree-sitter test (local machine is missing the external tree-sitter CLI; its Node binding subtest passed)

Checklist

  • My code follows the project's coding style
  • I have reviewed my own diff
  • I have added/updated documentation as needed
  • This change does not introduce new warnings

@qingliaowu qingliaowu marked this pull request as ready for review May 6, 2026 06:10
awli pushed a commit that referenced this pull request May 13, 2026
The Prerequisites section listed only "Node.js >= 20 and pnpm >= 8",
missing the tree-sitter CLI requirement that `pnpm build` needs to
generate the parser in `packages/parser-tree-sitter`. New contributors
hit "sh: tree-sitter: command not found" with no guidance from the
README.

Recommends `mise install` as the primary setup path (respects the
pinned 0.25.x line in mise.toml) and provides a manual-install
fallback that explicitly lists Node 22, pnpm 10, and the tree-sitter
CLI 0.25.x. Calls out the macOS Homebrew gotcha: `brew install
tree-sitter` ships only the C library; the CLI is a separate
`tree-sitter-cli` formula (which currently ships 0.26.x, a minor
mismatch with the pin).

Addresses #33 Part B (the undocumented CLI prerequisite). Part A
(Node 26 compatibility) is covered by #23 and #27.

Refs #33
@awli
Copy link
Copy Markdown
Contributor

awli commented May 13, 2026

Hi @qingliaowu, thanks for this contribution!

The lack of default compatibility with C++20 in tree-sitter has bugged me for a while, so thanks for looking at this.

Could you let me know your thoughts about whether it's ok to use patchedDependencies like this in a way that doesn't allow us to use just bare npm? Do you think that will be an issue?

@qingliaowu
Copy link
Copy Markdown
Author

qingliaowu commented May 14, 2026

@awli

Hi @qingliaowu, thanks for this contribution!

The lack of default compatibility with C++20 in tree-sitter has bugged me for a while, so thanks for looking at this.

Could you let me know your thoughts about whether it's ok to use patchedDependencies like this in a way that doesn't allow us to use just bare npm? Do you think that will be an issue?

Thanks for raising that. I agree bare npm compatibility is worth thinking about.

I checked whether we could avoid the pnpm-only patch. There is not a newer published tree-sitter npm release yet, but upstream has moved toward conditional C++ standard handling in binding.gyp. I updated this PR’s patch to follow that upstream-style logic instead of forcing C++20 unconditionally.

Given this repo already standardizes on pnpm via packageManager, pnpm-lock.yaml, and CI, I think patchedDependencies is acceptable as a temporary workaround. The tradeoff is that bare npm install will not consume the patch; for npm users the current workaround remains setting CXXFLAGS=-std=c++20 until tree-sitter publishes a fixed release. Once that release is available, we can drop the patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] tree-sitter@0.25.0 fails to build with Node.js 24 - C++20 required but not set

2 participants