mislav/hub · error

This gist contains multiple files, you must specify one: %

Error message

This gist contains multiple files, you must specify one:
  %s

What it means

`gist view`/`getGist` fetches a gist that contains more than one file, but no filename argument was supplied. Since the command cannot decide which file's content to print, it lists all file names sorted alphabetically and aborts. This is an interactive-disambiguation error: re-run naming one of the listed files.

Source

Thrown at commands/gist.go:92

func init() {
	cmdGist.Use(cmdShowGist)
	cmdGist.Use(cmdCreateGist)
	CmdRunner.Use(cmdGist)
}

func getGist(gh *github.Client, id string, filename string) error {
	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) {

View on GitHub (pinned to 5c547ed804)

Solutions

  1. Re-run the command with the desired file name: `gh gist view <id> <filename>`.
  2. Pick one of the file names exactly as listed in the error message (it prints all valid options).
  3. In scripts, capture the first listed name programmatically or loop over all files.

Example fix

// before
gh gist view abc123            # multi-file gist -> error
// after
gh gist view abc123 config.yml
Defensive patterns

Strategy: validation

Validate before calling

// Fetch the gist and inspect file count before viewing
 gist := fetchGist(gistID)
if len(gist.Files) > 1 && filename == "" {
    for name := range gist.Files {
        fmt.Println(name)
    }
    os.Exit(1) // force explicit file selection
}

Prevention

When it happens

Trigger: Calling `gh gist view <id>` (via showGist -> getGist) where the gist's `Files` map has length > 1 and the `filename` argument is empty.

Common situations: Pasting a gist URL that contains several files (common with multi-file gists); scripts that assumed single-file gists; gist was edited to add files after the script was written.

Related errors


AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01). Data as JSON: /api/errors/8555801177f918e4. Report an issue: GitHub.