jdx/mise · error · eyre::Report

no GitHub token found for {}

Error message

no GitHub token found for {}

What it means

`mise token github --raw` requires that a GitHub token actually exists for the requested --host; mise checked its token sources (e.g. GITHUB_TOKEN/GH_TOKEN-style env vars and `gh` CLI auth) and found none. Without --raw the same state just prints `host: (none)`, so the error is specific to --raw (and by extension piping --raw into another command).

Source

Thrown at src/cli/token/github.rs:66

        } else {
            github::resolve_token(&self.host)
        };
        match resolved {
            Some((token, source)) => {
                if self.raw {
                    miseprintln!("{token}");
                    return Ok(());
                }
                let display_token = if self.unmask {
                    token
                } else {
                    tokens::mask_token(&token)
                };
                miseprintln!("{}: {} (source: {})", self.host, display_token, source);
            }
            None => {
                if self.raw {
                    bail!("no GitHub token found for {}", self.host);
                }
                miseprintln!("{}: (none)", self.host);
            }
        }
        Ok(())
    }
}

static AFTER_LONG_HELP: &str = color_print::cstr!(
    r#"<bold><underline>Examples:</underline></bold>

    $ <bold>mise token github</bold>
    github.com: ghp_…xxxx (source: GITHUB_TOKEN)

    $ <bold>mise token github --unmask</bold>
    github.com: ghp_xxxxxxxxxxxx (source: GITHUB_TOKEN)

    $ <bold>mise token github github.mycompany.com</bold>

View on GitHub (pinned to 9dcfcaa0dc)

Solutions

  1. Export a token before the call: `export GITHUB_TOKEN=ghp_...` (or the enterprise variant for custom hosts) then rerun
  2. Authenticate the gh CLI: `gh auth login` — mise reads its stored token
  3. If you just want to inspect state, drop --raw: `mise token github` prints `(none)` instead of failing

Example fix

# before
$ mise token github --raw
# error: no GitHub token found for github.com

# after
$ export GITHUB_TOKEN="$MY_CI_TOKEN"
$ mise token github --raw
Defensive patterns

Strategy: validation

Validate before calling

: "${GITHUB_TOKEN:?no GITHUB_TOKEN set — mise token github --raw would fail}"
mise token github --raw

Try / catch

token="$(mise token github --raw)" || { echo 'no GitHub token: export GITHUB_TOKEN or run gh auth login' >&2; exit 1; }

Prevention

When it happens

Trigger: `mise token github --raw` with no token configured anywhere; `--raw --host github.example.com` where no enterprise token (GH_ENTERPRISE_TOKEN etc.) is set for that host.

Common situations: CI scripts consuming `mise token github --raw` before any credential step ran; using a custom GHE host without its enterprise token env var; fresh machine where `gh auth login` was never run.

Related errors


AI-assisted analysis of jdx/mise@9dcfcaa0dc (2026-08-17). Data as JSON: /api/errors/d15be5837ccd7123. Report an issue: GitHub.