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

  1. Pass a license keyword: gh repo license view mit
  2. List valid keywords: gh api /licenses -q '.[].key'
  3. 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

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


AI-assisted analysis of cli/cli@0eeec0b92e (2026-08-15). Data as JSON: /api/errors/015df4e8eb25d31e. Report an issue: GitHub.