oven-sh/bun · error · bun_install::Error
InvalidURL
Error message
InvalidURL
What it means
A URL used by the install pipeline failed validation. Depending on the path: the WHATWG URL parser could not parse the string at all (url/lib.rs:323), or the resolved registry/package URL was rejected because it is not http(s):// (NetworkTask.rs:498-518), the registry and package URLs could not be joined (NetworkTask.rs:495), or the manifest URL is not on the configured registry's host/port/path (NetworkTask.rs:530-558).
Source
Thrown at src/install/error.rs:147
#[error("MissingPackageField")]
MissingPackageField,
#[error("InvalidPackageField")]
InvalidPackageField,
#[error("EmptyPackageField")]
EmptyPackageField,
#[error("InvalidDescriptionField")]
InvalidDescriptionField,
#[error("InvalidUrlField")]
InvalidUrlField,
#[error("MissingLevelField")]
MissingLevelField,
#[error("InvalidLevelField")]
InvalidLevelField,
#[error("InvalidLevelValue")]
InvalidLevelValue,
#[error("Missing global bin directory: try setting $BUN_INSTALL")]
MissingGlobalBinDirectoryTrySettingBUNINSTALL,
#[error("InvalidURL")]
InvalidURL,
#[error("Fail")]
Fail,
#[error("IntegrityCheckFailed")]
IntegrityCheckFailed,
#[error("RepositoryNotFound")]
RepositoryNotFound,
#[error("DebugTextLockfileRoundTrip")]
DebugTextLockfileRoundTrip,
#[error("NoPackage")]
NoPackage,
#[error("BrokenPipe")]
BrokenPipe,
#[error("WriteFailed")]
WriteFailed,
#[error("InvalidCharacter")]
InvalidCharacter,
#[error("InvalidLockfile")]View on GitHub (pinned to 8c5296ac45)
Solutions
- Check the printed 'Registry URL must be http:// or https://' / 'Invalid package name' message for the exact offending URL and fix its scheme or spelling
- Give the registry URL a full scheme: https://registry.npmjs.org (not registry.npmjs.org)
- For mirrors that redirect to another host, configure the final host as the registry so manifest URLs stay on it
- Verify the scope→registry mapping in package.json npmScopes / bunfig.toml matches where packages actually resolve
Example fix
# before (bunfig.toml) [install] registry = "registry.corp.internal" # after [install] registry = "https://registry.corp.internal"
Defensive patterns
Strategy: validation
Validate before calling
# validate registry URLs carry a scheme and parse before installing for url in $(grep -oP '(registry|url)\s*=\s*"\K[^"]+' bunfig.toml); do case "$url" in https://*|http://*) ;; *) echo "bad registry URL (need http(s)://): $url" >&2; exit 1;; esac done
Type guard
// in JS tooling wrapping bun: check URLs up front
const okRegistry = (u) => { try { const p = new URL(u); return p.protocol === "http:" || p.protocol === "https:"; } catch { return false; } }; Prevention
- Always write registry URLs with a full https:// scheme in bunfig.toml and npmScopes
- For mirrors/proxies that redirect to a CDN host, configure the final host as the registry
- Keep scope→registry mappings consistent with where manifests actually resolve
When it happens
Trigger: Setting a custom registry (npmScopes, --registry, or install.registry in bunfig.toml) to a value with a bad scheme (e.g. "registry.corp" without https://), a malformed URL, or a package whose tarball/manifest URL points to a different host than the registry — common with registry mirrors that redirect to a CDN on another domain.
Common situations: Typos in bunfig.toml registry URLs (missing protocol, trailing garbage); Artifactory/Nexus/proxy registries that redirect to a different hostname; scope configuration where the scoped registry differs from where the manifest actually resolves; git+ssh style URLs used where an https URL is required.
Related errors
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/94f674b38a661896.
Report an issue: GitHub.