Skip to content

misc Windows fixes#5256

Merged
WillLillis merged 2 commits intotree-sitter:masterfrom
WillLillis:windows_stuff
Jan 25, 2026
Merged

misc Windows fixes#5256
WillLillis merged 2 commits intotree-sitter:masterfrom
WillLillis:windows_stuff

Conversation

@WillLillis
Copy link
Member

@WillLillis WillLillis commented Jan 25, 2026

Three separate changes:

  • Since feat(loader): replace usage nm with object crate #5252 is a no-go, we should at least warn users when building on Windows that we can't verify the symbols of their built parsers. This warning will print every time tree-sitter b is run on Windows, but I think that's better than potentially silently failing.
  • I missed this while testing feat: dynamically expose queries in bindings #4955, but since the path separator on Windows is \, this gets treated as an escape slash when in a grammar's rust bindings files, causing a build failure. The unix / works for both platforms (at least where we're placing those paths in lib.rs and build.rs), so it's easiest to just go with that.
Build failure with a newly init`'d grammar's rust bindings on 0.26.3:
C:\Users\willl\source\repos\ts_test>cargo build
    Updating crates.io index
     Locking 24 packages to latest compatible versions
   Compiling find-msvc-tools v0.1.8
   Compiling tree-sitter-language v0.1.6
   Compiling shlex v1.3.0
   Compiling cc v1.2.54
   Compiling tree-sitter-ts-test v0.1.0 (C:\Users\willl\source\repos\ts_test)
error: unknown character escape: `h`
  --> bindings\rust\build.rs:41:18
   |
41 |     if !"queries\highlights.scm".is_empty() && std::path::Path::new("queries\highlights.scm").exists() {
   |                  ^ unknown character escape
   |
   = help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals>
help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal
   |
41 |     if !r"queries\highlights.scm".is_empty() && std::path::Path::new("queries\highlights.scm").exists() {
   |         +

error: unknown character escape: `h`
  --> bindings\rust\build.rs:41:78
   |
41 |     if !"queries\highlights.scm".is_empty() && std::path::Path::new("queries\highlights.scm").exists() {
   |                                                                              ^ unknown character escape
   |
   = help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals>
help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal
   |
41 |     if !"queries\highlights.scm".is_empty() && std::path::Path::new(r"queries\highlights.scm").exists() {
   |                                                                     +

error: unknown character escape: `i`
  --> bindings\rust\build.rs:45:18
   |
45 |     if !"queries\injections.scm".is_empty() && std::path::Path::new("queries\injections.scm").exists() {
   |                  ^ unknown character escape
   |
   = help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals>
help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal
   |
45 |     if !r"queries\injections.scm".is_empty() && std::path::Path::new("queries\injections.scm").exists() {
   |         +

error: unknown character escape: `i`
  --> bindings\rust\build.rs:45:78
   |
45 |     if !"queries\injections.scm".is_empty() && std::path::Path::new("queries\injections.scm").exists() {
   |                                                                              ^ unknown character escape
   |
   = help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals>
help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal
   |
45 |     if !"queries\injections.scm".is_empty() && std::path::Path::new(r"queries\injections.scm").exists() {
   |                                                                     +

error: unknown character escape: `l`
  --> bindings\rust\build.rs:49:18
   |
49 |     if !"queries\locals.scm".is_empty() && std::path::Path::new("queries\locals.scm").exists() {
   |                  ^ unknown character escape
   |
   = help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals>
help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal
   |
49 |     if !r"queries\locals.scm".is_empty() && std::path::Path::new("queries\locals.scm").exists() {
   |         +

error: unknown character escape: `l`
  --> bindings\rust\build.rs:49:74
   |
49 |     if !"queries\locals.scm".is_empty() && std::path::Path::new("queries\locals.scm").exists() {
   |                                                                          ^ unknown character escape
   |
   = help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals>
help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal
   |
49 |     if !"queries\locals.scm".is_empty() && std::path::Path::new(r"queries\locals.scm").exists() {
   |                                                                 +

error: could not compile `tree-sitter-ts-test` (build script) due to 6 previous errors
  • Address a new nightly lint

@WillLillis WillLillis changed the title fix(cli): warn user when library symbols can't be checked on Windows misc Windows fixes Jan 25, 2026
@WillLillis WillLillis added cli templates Related to bindings templates ci:backport release-0.26 Backport label labels Jan 25, 2026
@clason
Copy link
Contributor

clason commented Jan 25, 2026

This warning will print every time tree-sitter b is run on Windows, but I think that's better than potentially silently failing.

Hmm, that's not great. (Remember nvim-treesitter uses tree-sitter build.)

I'd rather skip the step entirely (and silently) on Windows and document that somewhere.

@clason
Copy link
Contributor

clason commented Jan 25, 2026

Also, I think these fixes should be separate PRs so we can backport them individually (and quickly; I'd like to get a 0.26.4 out with the array fixes asap).

@WillLillis
Copy link
Member Author

WillLillis commented Jan 25, 2026

This warning will print every time tree-sitter b is run on Windows, but I think that's better than potentially silently failing.

Hmm, that's not great. (Remember nvim-treesitter uses tree-sitter build.)

I'd rather skip the step entirely (and silently) on Windows and document that somewhere.

Dropped the symbols warning, will put up a PR for the docs shortly.

@WillLillis WillLillis merged commit c013720 into tree-sitter:master Jan 25, 2026
25 of 26 checks passed
@WillLillis WillLillis deleted the windows_stuff branch January 25, 2026 22:18
@tree-sitter-ci-bot
Copy link

Successfully created backport PR for release-0.26:

@tree-sitter-ci-bot tree-sitter-ci-bot bot mentioned this pull request Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:backport release-0.26 Backport label cli templates Related to bindings templates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants