{"record":{"id":"2c3bba2edcefbe8e","repo":"jdx/mise","slug":"could-not-auto-detect-platform-from-url-pleas","errorCode":null,"errorMessage":"Could not auto-detect platform from URL: {}. Please specify explicitly using 'platform:url' format.","messagePattern":"Could not auto-detect platform from URL: (.+?)\\. Please specify explicitly using 'platform:url' format\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/generate/tool_stub.rs","lineNumber":529,"sourceCode":"__mise_tool_stub_bootstrap\n\nexec \"$MISE_BIN\" tool-stub \"$0\" \"$@\"\n\"##\n        ))\n    }\n\n    fn parse_platform_spec(&self, spec: &str) -> Result<(String, String)> {\n        // Check if this is a URL first (auto-detect case)\n        if spec.starts_with(\"http://\") || spec.starts_with(\"https://\") {\n            // Format: url (auto-detect platform)\n            let url = spec.to_string();\n\n            if let Some(detected_platform) = detect_platform_from_url(&url) {\n                let platform = detected_platform.to_platform_string();\n                debug!(\"Auto-detected platform '{}' from URL: {}\", platform, url);\n                Ok((platform, url))\n            } else {\n                bail!(\n                    \"Could not auto-detect platform from URL: {}. Please specify explicitly using 'platform:url' format.\",\n                    url\n                );\n            }\n        } else {\n            // Format: platform:url\n            let parts: Vec<&str> = spec.splitn(2, ':').collect();\n            if parts.len() != 2 {\n                bail!(\n                    \"Platform spec must be in format 'platform:url' or just 'url' (for auto-detection). Got: {}\",\n                    spec\n                );\n            }\n\n            let platform = parts[0].to_string();\n            let url = parts[1].to_string();\n            Ok((platform, url))\n        }","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/cli/generate/tool_stub.rs#L511-L547","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Prefix the URL with its platform explicitly, e.g. `--platform-url github=https://...` or `--url https:...` per the accepted platform keys","Use a recognized host (GitHub/GitLab releases, crates.io, npm) that auto-detection supports","Verify the URL is well-formed; fix typos in the hostname that break detection"],"exampleFix":"// before\nmise generate tool-stub --url https://downloads.example.com/mytool-1.0.tar.gz\n// after\nmise generate tool-stub --platform-url https=https://downloads.example.com/mytool-1.0.tar.gz","handlingStrategy":"validation","validationCode":"const KNOWN = /^https:\\/\\/(github\\.com|gitlab\\.com|crates\\.io|registry\\.npmjs\\.org)\\//;\nif (!/^[a-z]+:/.test(url) && !KNOWN.test(url)) {\n  throw new Error('prefix the URL with platform:, detection will fail for this host');\n}","typeGuard":"const hasPlatformPrefix = (url: string): boolean => /^[a-z][a-z0-9-]*:/.test(url);","tryCatchPattern":"try {\n  await exec(`mise generate tool-stub --url ${url}`);\n} catch (e) {\n  if (String(e).includes('Could not auto-detect platform')) {\n    await exec(`mise generate tool-stub --platform-url ${platform}=${url}`);\n  }\n}","preventionTips":["Always prefix URLs from custom/unknown hosts with their platform","Stick to GitHub/GitLab release URLs when auto-detection is preferred","Validate URL hostnames for typos before generating stubs"],"tags":["tool-stub","platform-detection","url","cli"],"backgroundTag":"invalid-url","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}