Skip to content

Commit 5b0e831

Browse files
committed
Fix tree-sitter not found after cargo install
Install-TreeSitter does not add ~/.cargo/bin to $env:PATH after running cargo install, unlike Install-Rust which does. When Rust is already present on the system (so Install-Rust is a no-op) and ~/.cargo/bin is not in the inherited PATH, the tree-sitter binary cannot be found by Export-GrammarBinding. Add the same PATH update logic that Install-Rust uses. Contact: johan.kallio@teamtech.se
1 parent 0530a16 commit 5b0e831

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

helpers.build.psm1

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,19 @@ function Install-TreeSitter {
500500
if ($LASTEXITCODE -ne 0) {
501501
throw "Failed to install tree-sitter-cli"
502502
}
503+
504+
# Ensure cargo bin directory is in PATH so tree-sitter can be found
505+
if (!$IsWindows) {
506+
$cargoBin = "$env:HOME/.cargo/bin"
507+
if ($env:PATH -notlike "*$cargoBin*") {
508+
$env:PATH += ":$cargoBin"
509+
}
510+
} else {
511+
$cargoBin = "$env:USERPROFILE\.cargo\bin"
512+
if ($env:PATH -notlike "*$cargoBin*") {
513+
$env:PATH += ";$cargoBin"
514+
}
515+
}
503516
}
504517
}
505518

0 commit comments

Comments
 (0)