{"record":{"id":"6d30d57b24c7858b","repo":"denoland/deno","slug":"failed-to-install-specifier-if-you-are-tryin","errorCode":null,"errorMessage":"Failed to install \"{}\" specifier. If you are trying to install {} globally, run again with `-g` flag:\n  deno install -g {}","messagePattern":"Failed to install \"(.+?)\" specifier\\. If you are trying to install (.+?) globally, run again with `-g` flag:\n  deno install -g (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/tools/installer/local.rs","lineNumber":502,"sourceCode":"    log::info!(\"  installed {} jsr package(s)\", installed.len());\n  }\n  Ok(())\n}\n\npub fn check_if_installs_a_single_package_globally(\n  maybe_add_flags: Option<&AddFlags>,\n) -> Result<(), AnyError> {\n  let Some(add_flags) = maybe_add_flags else {\n    return Ok(());\n  };\n  if add_flags.packages.len() != 1 {\n    return Ok(());\n  }\n  let Ok(url) = Url::parse(&add_flags.packages[0]) else {\n    return Ok(());\n  };\n  if matches!(url.scheme(), \"http\" | \"https\") {\n    bail!(\n      \"Failed to install \\\"{}\\\" specifier. If you are trying to install {} globally, run again with `-g` flag:\\n  deno install -g {}\",\n      url.scheme(),\n      url.as_str(),\n      url.as_str()\n    );\n  }\n  Ok(())\n}\n","sourceCodeStart":484,"sourceCodeEnd":511,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/tools/installer/local.rs#L484-L511","documentation":"When a local add-style install receives exactly one package argument that parses as an http/https URL, Deno refuses it: remote URL scripts are not project dependencies (they don't go in deno.json/package.json), they are global executables. The error names the scheme ('http'/'https') and suggests the global form.","triggerScenarios":"Conditions at cli/tools/installer/local.rs:502: exactly one package in add_flags, Url::parse succeeds, and url.scheme() is http or https. E.g. `deno add https://example.com/tool.ts` or `deno install <url>` in local mode.","commonSituations":"Users migrating from `deno install https://...` one-off tool installs; trying to 'add' a CDN script as a dependency instead of using an npm:/jsr: package.","solutions":["Install it globally: `deno install -g <https-url>`","If you wanted a project dependency, add the real package instead: `deno add npm:<pkg>` or `deno add jsr:<pkg>`","For one-off runs without installing, use `deno run <https-url>`"],"exampleFix":"# before\ndeno add https://example.com/tool.ts\n\n# after (global executable)\ndeno install -g https://example.com/tool.ts\n\n# after (project dependency instead)\ndeno add npm:chalk","handlingStrategy":"validation","validationCode":"# route by scheme before invoking install/add:\nif [[ \"$spec\" == https://* || \"$spec\" == http://* ]]; then deno install -g \"$spec\"; else deno add \"$spec\"; fi","typeGuard":"// JS\nconst isRemoteScript = (s) => /^https?:\\/\\//.test(s);\n// if (isRemoteScript(spec)) -> deno install -g spec, else deno add spec","tryCatchPattern":"Catch the 'Failed to install \"https\" specifier' bail and re-run the exact `deno install -g <url>` command the message prints.","preventionTips":["Use npm:/jsr: specifiers for project dependencies; reserve http(s) URLs for `deno install -g`","For one-off runs use `deno run <url>` instead of installing"],"tags":["install","add","remote-url","global-install","scheme"],"backgroundTag":"global-vs-local-install-mismatch","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}