Skip to content

fix(cli): improve error message in cases where a langauge can't be found for one of many paths#4643

Merged
clason merged 1 commit intotree-sitter:masterfrom
WillLillis:path_error
Aug 2, 2025
Merged

fix(cli): improve error message in cases where a langauge can't be found for one of many paths#4643
clason merged 1 commit intotree-sitter:masterfrom
WillLillis:path_error

Conversation

@WillLillis
Copy link
Member

The Problem:

When multiple input paths are provided to the parse command (a la tree-sitter parse --paths [...]), if a language can't be found for one of the paths, it can be a little unclear which path caused the failure. The loader can fail with Failed to load language for file name <foo.bar>, but this isn't guaranteed.

The Solution:

Attach some additional context in the case where multiple paths can be provided, displaying the problematic path on failure.

Before:

$ tree-sitter parse foo.bar
No language found

After:

$ tree-sitter parse foo.bar
Failed to load langauge for path "foo.bar"

Caused by:
    No language found

This use case was brought up by digitcrusher in the community chat.

@clason clason merged commit 9ced617 into tree-sitter:master Aug 2, 2025
20 checks passed
@tree-sitter-ci-bot
Copy link

github-actions bot pushed a commit that referenced this pull request Aug 2, 2025
…4643)

Problem: When multiple input paths are provided to the `parse` command (a la `tree-sitter parse --paths [...]`), if a language can't be found for one of the paths, it can be a little unclear *which* path caused the failure. The loader *can* fail with `Failed to load language for file name <foo.bar>`, but this isn't guaranteed.

Solution: Attach some additional context in the case where multiple paths can be provided, displaying the problematic path on failure.
(cherry picked from commit 9ced617)
clason pushed a commit that referenced this pull request Aug 2, 2025
…4643)

Problem: When multiple input paths are provided to the `parse` command (a la `tree-sitter parse --paths [...]`), if a language can't be found for one of the paths, it can be a little unclear *which* path caused the failure. The loader *can* fail with `Failed to load language for file name <foo.bar>`, but this isn't guaranteed.

Solution: Attach some additional context in the case where multiple paths can be provided, displaying the problematic path on failure.
(cherry picked from commit 9ced617)
@WillLillis WillLillis deleted the path_error branch August 2, 2025 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants