cli/cli · error
no license provided
Error message
no license provided
What it means
Simple argument check in `gh repo license view`: the license keyword (the sole positional argument) is required; with an empty license the command stops immediately before contacting the API. The license must be one of the keys GitHub's licenses API accepts (e.g. mit, apache-2.0, agpl-3.0).
Source
Thrown at pkg/cmd/repo/license/view/view.go:77
`),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
opts.License = args[0]
if runF != nil {
return runF(opts)
}
return viewRun(opts)
},
}
cmd.Flags().BoolVarP(&opts.Web, "web", "w", false, "Open https://choosealicense.com/ in the browser")
return cmd
}
func viewRun(opts *ViewOptions) error {
if opts.License == "" {
return errors.New("no license provided")
}
client, err := opts.HTTPClient()
if err != nil {
return err
}
cfg, err := opts.Config()
if err != nil {
return err
}
if err := opts.IO.StartPager(); err != nil {
fmt.Fprintf(opts.IO.ErrOut, "starting pager failed: %v\n", err)
}
defer opts.IO.StopPager()
hostname, _ := cfg.Authentication().DefaultHost()View on GitHub (pinned to 0eeec0b92e)
Solutions
- Pass a license keyword: gh repo license view mit
- List valid keywords: gh api /licenses -q '.[].key'
- Default script variables: "${LICENSE:-mit}"
Example fix
# before gh repo license view # after gh repo license view mit
Defensive patterns
Strategy: validation
Validate before calling
if strings.TrimSpace(licenseKey) == "" {
return errors.New("license key is required, e.g. gh repo license view mit")
} Prevention
- Validate non-empty arguments before invoking gh in scripts
- List valid keys: gh api /licenses -q '.[].key'
- Default the variable: "${LICENSE:-mit}"
When it happens
Trigger: Running `gh repo license view` without a positional argument outside the interactive picker, or calling viewRun with an empty License field. Passing an invalid (non-empty) license instead produces a server 404, not this error.
Common situations: Scripts omitting the argument or passing an unset shell variable; users expecting --web alone to work without specifying a license.
Related errors
- no template provided
- invalid key: %q
- field %q requires a value separated by an '=' sign
- expected array type under %q, got %T
- unexpected override existing field under %q
AI-assisted analysis of cli/cli@0eeec0b92e (2026-08-15).
Data as JSON: /api/errors/015df4e8eb25d31e.
Report an issue: GitHub.