Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing (for Noobs) error message when used to analyse Single File which is not committed into Git Repo #7162

Open
vorburger opened this issue Dec 14, 2024 · 2 comments
Labels

Comments

@vorburger
Copy link
Contributor

https://github.com/github-linguist/linguist#single-file says you can do e.g. github-linguist README.md.

This works, of course - but only if the file is actually committed into a Git repository, and otherwise fails with a (to me) obscure internal error.

This confused the hell out of me, and it took me a fair bit of trial and error to narrow this down to being root cause related to the file is actually committed into a Git repository.

In an ideal world, it might be cool if Linguist also just worked for uncommitted files?

Unless this is a deliberate design decision, and not just an oversight, or regression? If that's the case, a clear error message would be neat.

Here are the fully reproducible technical details of what actually currently happens:

$ bin/github-linguist README.md
README.md: 228 lines (167 sloc)
  type:      Text
  mime type: text/markdown
  language:  Markdown

$ cp README.md README2.md

$ bin/github-linguist README2.md
/home/vorburger/git/github.com/github-linguist/linguist/lib/linguist/source/rugged.rb:65:in `to_buffer': wrong argument type nil (expected String) (TypeError)

        Rugged::Blob.to_buffer(@rugged, blob_id, max_size)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^
        from /home/vorburger/git/github.com/github-linguist/linguist/lib/linguist/source/rugged.rb:65:in `load_blob'
        from /home/vorburger/git/github.com/github-linguist/linguist/lib/linguist/lazy_blob.rb:117:in `load_blob!'
        from /home/vorburger/git/github.com/github-linguist/linguist/lib/linguist/lazy_blob.rb:91:in `data'
        from /home/vorburger/git/github.com/github-linguist/linguist/lib/linguist/blob_helper.rb:127:in `binary?'
        from /home/vorburger/git/github.com/github-linguist/linguist/lib/linguist/blob_helper.rb:155:in `text?'
        from bin/github-linguist:112:in `github_linguist'
        from bin/github-linguist:155:in `<main>'
@lildude
Copy link
Member

lildude commented Dec 15, 2024

Unless this is a deliberate design decision, and not just an oversight, or regression?

It is deliberate. Linguist runs on GitHub's servers against bare repos which means there are no individual files to analyse. We have a point about this in the troubleshooting doc.

That said, this used to work. I suspect #7094 may have inadvertently broken this.

@vorburger
Copy link
Contributor Author

FYI my "use case" which made me raise this was simply trying to contribute to Linguist (for #7161) and trying to verify a fix on file which was not (yet) committed in the repo. Understanding the cause of this error, through trial and error, is where I spent the majority of the time 🤣 when I put together #7163.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants