Skip to content

Fix tree-sitter not found after cargo install#1431

Open
skabbio1976 wants to merge 1 commit intoPowerShell:mainfrom
skabbio1976:fix/tree-sitter-path
Open

Fix tree-sitter not found after cargo install#1431
skabbio1976 wants to merge 1 commit intoPowerShell:mainfrom
skabbio1976:fix/tree-sitter-path

Conversation

@skabbio1976
Copy link

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
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.

1 participant