tree-sitter / tree-sitter-rust

Rust grammar for tree-sitter
MIT License
357 stars 101 forks source link

Mark compatible with tree-sitter 0.22 #247

Open joshka opened 3 days ago

joshka commented 3 days ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

Dependabot wants to update tree-sitter in a repo I own, but this is not marked as compatible.

Steps To Reproduce/Bad Parse Tree

a

Expected Behavior/Parse Tree

a

Repro

No response

amaanq commented 3 days ago

tree-sitter is no longer a dependency of any language crate.

joshka commented 3 days ago

tree-sitter is a peer-dep of tree-sitter-rust, and locked to 0.21.x (where x>1)

https://github.com/tree-sitter/tree-sitter-rust/blob/32c17ce5463818032a9c252a849b910315b6e485/package.json#L49-L51

The latest release of tree-sitter is 0.22.1. I'm not sure exactly what's changed / updated as there's no github release for tree-sitter-node 0.22.x. The first I knew about it was dependabot suggesting that I update my dependency on tree-sitter (in an app that uses it) to 0.22.x, and seeing this fail due to this being incompatible with the latest version of tree-sitter-rust.

tree-sitter-rust works with tree-sitter 0.21:

❯ grep -E 'ependencie|tree-sit' package.json                                              
  "dependencies": {
    "tree-sitter": "0.21.1",
    "tree-sitter-rust": "^0.23.1",

npm i succeeds

With tree-sitter set to exactly 0.22.1, npm warns about finding deps

❯ grep -E 'ependencie|tree-sit' package.json
  "dependencies": {
    "tree-sitter": "0.22.1",
    "tree-sitter-rust": "^0.23.1",

npm i

❯ npm i
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: ratatui.rs@0.0.1
npm WARN Found: tree-sitter@0.21.1
npm WARN node_modules/tree-sitter
npm WARN   tree-sitter@"0.22.1" from the root project
npm WARN   1 more (tree-sitter-rust)
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peerOptional tree-sitter@"^0.21.1" from tree-sitter-rust@0.23.1
npm WARN node_modules/tree-sitter-rust
npm WARN   tree-sitter-rust@"^0.23.1" from the root project

with tree-sitter set to ^0.22.1, and latest tree-sitter-rust, npm install fails

❯ grep -E 'ependencie|tree-sit' package.json
  "dependencies": {
    "tree-sitter": "^0.22.1",
    "tree-sitter-rust": "^0.23.1",
  "devDependencies": {
❯ npm i                                     
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: tree-sitter-rust@0.23.1
npm ERR! Found: tree-sitter@0.22.1
npm ERR! node_modules/tree-sitter
npm ERR!   tree-sitter@"^0.22.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional tree-sitter@"^0.21.1" from tree-sitter-rust@0.23.1
npm ERR! node_modules/tree-sitter-rust
npm ERR!   tree-sitter-rust@"^0.23.1" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: tree-sitter@0.21.1
npm ERR! node_modules/tree-sitter
npm ERR!   peerOptional tree-sitter@"^0.21.1" from tree-sitter-rust@0.23.1
npm ERR!   node_modules/tree-sitter-rust
npm ERR!     tree-sitter-rust@"^0.23.1" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /Users/joshka/.npm/_logs/2024-11-21T11_02_53_941Z-eresolve-report.txt

This is in a website (https://ratatui.rs) where we have some code extract rust example code based on the function name, so we use tree-sitter and tree-sitter-rust there.

I'm not 100% sure that what I'm asking for here is the correct thing (my knowledge of node deps is not particularly deep), so perhaps I'm asking something the wrong way here (or perhaps I just need to ignore the suggestion to update to the latest version of tree-sitter which is incompatible with tree-sitter-rust?

joshka commented 3 days ago

https://github.com/ratatui/ratatui-website/pull/772 is a failing dependabot PR (it was a larger one, but I've manually resolved the other relevant updates)

amaanq commented 7 hours ago

Oh I see, that's my mistake. I thought you were talking about the Rust crate here :sweat_smile: sorry about that

joshka commented 7 hours ago

Ah got it - I see the where the confusion stems from now. My knowledge of the innards of tree-sitter are basically non-existent. it's like 20-30 lines of code in our website at https://github.com/ratatui/ratatui-website/blob/1b1f4100c3a3ee5ccfd1075e564fed49109bcbd0/src/plugins/remark-code-import.ts#L123-L157. So much of this was my problem of miscommunicating the problem.