jdx/mise · error

Could not auto-detect platform from URL

Error message

Could not auto-detect platform from URL: {}. Please specify explicitly using 'platform:url' format.

What it means

When a bare URL is given to `mise generate tool-stub` without a platform prefix, mise attempts to infer the platform (e.g. github, npm) from URL shape via `detect_platform_from_url`. If detection fails, mise bails and asks the user to specify the platform explicitly in `platform:url` form. Platform detection is heuristic and only recognizes known URL patterns.

Solutions

  1. Prefix the URL with its platform explicitly, e.g. `--platform-url github=https://...` or `--url https:...` per the accepted platform keys
  2. Use a recognized host (GitHub/GitLab releases, crates.io, npm) that auto-detection supports
  3. Verify the URL is well-formed; fix typos in the hostname that break detection

Example fix

// before
mise generate tool-stub --url https://downloads.example.com/mytool-1.0.tar.gz
// after
mise generate tool-stub --platform-url https=https://downloads.example.com/mytool-1.0.tar.gz
Defensive patterns

Strategy: validation

Validate before calling

const KNOWN = /^https:\/\/(github\.com|gitlab\.com|crates\.io|registry\.npmjs\.org)\//;
if (!/^[a-z]+:/.test(url) && !KNOWN.test(url)) {
  throw new Error('prefix the URL with platform:, detection will fail for this host');
}

Type guard

const hasPlatformPrefix = (url: string): boolean => /^[a-z][a-z0-9-]*:/.test(url);

Try / catch

try {
  await exec(`mise generate tool-stub --url ${url}`);
} catch (e) {
  if (String(e).includes('Could not auto-detect platform')) {
    await exec(`mise generate tool-stub --platform-url ${platform}=${url}`);
  }
}

Prevention

When it happens

Trigger: Passing `--url` (or a bare URL entry) whose host/pattern is not recognizable — e.g. a custom CDN, self-hosted release server, or an unusual download URL — so `detect_platform_from_url` returns None.

Common situations: Hosting release artifacts on a private mirror or object store; using a less-common forge (Codeberg, Gitea) not covered by detection; typos in the URL hostname defeating pattern matching.

Understand the failure class

Background: "Invalid URL" / "URL cannot be empty": fix the malformed or missing URL behind request-construction failures — this error's family across 50 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/2c3bba2edcefbe8e. Report an issue: GitHub.

Appendix: source

Thrown at src/cli/generate/tool_stub.rs:529

__mise_tool_stub_bootstrap

exec "$MISE_BIN" tool-stub "$0" "$@"
"##
        ))
    }

    fn parse_platform_spec(&self, spec: &str) -> Result<(String, String)> {
        // Check if this is a URL first (auto-detect case)
        if spec.starts_with("http://") || spec.starts_with("https://") {
            // Format: url (auto-detect platform)
            let url = spec.to_string();

            if let Some(detected_platform) = detect_platform_from_url(&url) {
                let platform = detected_platform.to_platform_string();
                debug!("Auto-detected platform '{}' from URL: {}", platform, url);
                Ok((platform, url))
            } else {
                bail!(
                    "Could not auto-detect platform from URL: {}. Please specify explicitly using 'platform:url' format.",
                    url
                );
            }
        } else {
            // Format: platform:url
            let parts: Vec<&str> = spec.splitn(2, ':').collect();
            if parts.len() != 2 {
                bail!(
                    "Platform spec must be in format 'platform:url' or just 'url' (for auto-detection). Got: {}",
                    spec
                );
            }

            let platform = parts[0].to_string();
            let url = parts[1].to_string();
            Ok((platform, url))
        }

View on GitHub (pinned to 533346cc37)