Skip to content

Fix tree-sitter not found after cargo install#1431

Merged
SteveL-MSFT merged 1 commit intoPowerShell:mainfrom
skabbio1976:fix/tree-sitter-path
Mar 14, 2026
Merged

Fix tree-sitter not found after cargo install#1431
SteveL-MSFT merged 1 commit intoPowerShell:mainfrom
skabbio1976:fix/tree-sitter-path

Conversation

@skabbio1976
Copy link
Contributor

Summary

  • Install-TreeSitter does not add ~/.cargo/bin to $env:PATH after cargo install, unlike Install-Rust which does.
  • When Rust is already present (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.
  • Adds the same PATH update logic that Install-Rust already uses.

Repro

Build from Linux where ~/.cargo/bin is not in the shell's default PATH. The build fails with:

Invoke-Expression: The term 'tree-sitter' is not recognized as a name of a cmdlet,
function, script file, or executable program.

Fix

# Ensure cargo bin directory is in PATH so tree-sitter can be found
if (!$IsWindows) {
    $cargoBin = "$env:HOME/.cargo/bin"
    if ($env:PATH -notlike "*$cargoBin*") {
        $env:PATH += ":$cargoBin"
    }
} else {
    $cargoBin = "$env:USERPROFILE\.cargo\bin"
    if ($env:PATH -notlike "*$cargoBin*") {
        $env:PATH += ";$cargoBin"
    }
}

Contact: johan.kallio@teamtech.se for questions.

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
@SteveL-MSFT
Copy link
Member

@skabbio1976 Thanks for the fix!

@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Mar 14, 2026
Merged via the queue into PowerShell:main with commit cc3cae5 Mar 14, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants