mislav/hub · error
no such file in gist
Error message
no such file in gist
What it means
`getGist` was given an explicit filename that does not exist in the fetched gist's `Files` map. The gist itself is valid and reachable; only the file key lookup failed. File names are case-sensitive and must match exactly as stored on GitHub.
Source
Thrown at commands/gist.go:99
gist, err := gh.FetchGist(id)
if err != nil {
return err
}
if len(gist.Files) > 1 && filename == "" {
filenames := []string{}
for name := range gist.Files {
filenames = append(filenames, name)
}
sort.Strings(filenames)
return fmt.Errorf("This gist contains multiple files, you must specify one:\n %s", strings.Join(filenames, "\n "))
}
if filename != "" {
if val, ok := gist.Files[filename]; ok {
ui.Println(val.Content)
} else {
return fmt.Errorf("no such file in gist")
}
} else {
for name := range gist.Files {
file := gist.Files[name]
ui.Println(file.Content)
}
}
return nil
}
func printGistHelp(command *Command, args *Args) {
utils.Check(command.UsageError(""))
}
func createGist(cmd *Command, args *Args) {
args.NoForward()
host, err := github.CurrentConfig().DefaultHostNoPrompt()View on GitHub (pinned to 5c547ed804)
Solutions
- Run `gh gist view <gist-id>` without a filename to see the exact list of file names, then use one verbatim.
- Check spelling and case — file keys are case-sensitive, including the extension.
- Re-fetch the gist to confirm the file still exists; it may have been edited/deleted.
Example fix
// before gh gist view abc123 readme.md # actual file is README.md // after gh gist view abc123 README.md
Defensive patterns
Strategy: validation
Validate before calling
gist := fetchGist(gistID)
if _, ok := gist.Files[filename]; !ok {
fmt.Printf("available files: ")
for name := range gist.Files {
fmt.Printf("%s ", name)
}
fmt.Println()
os.Exit(1)
} Type guard
func fileInGist(gist *github.Gist, name string) bool {
_, ok := gist.Files[name]
return ok
} Prevention
- List gist files first (`gh gist view <id>`) and use names verbatim.
- Remember file lookups are case-sensitive and require the exact extension.
- Re-check gists referenced in scripts — files can be edited or removed.
When it happens
Trigger: Running `gh gist view <gist-id> <filename>` (showGist -> getGist) where `gist.Files[filename]` is absent — typo, wrong case, missing extension, or file deleted from the gist.
Common situations: Typos or case mismatch (README.md vs readme.md); omitting the file extension; the file was removed from the gist after the command/script was written; copy-pasting a name from a different gist.
Related errors
- This gist contains multiple files, you must specify one: %
- error: no milestone found with name '%s'
- Error: No pull request number given
- no open pull requests found for branch '%s'
- Unable to find release with tag name `%s'
AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01).
Data as JSON: /api/errors/cabbf540aa0addae.
Report an issue: GitHub.