Skip to content

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

@vorburger

Description

@vorburger

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions