yarnpkg/yarn · error · MessageError
hostedGitResolveError
Error message
hostedGitResolveError
What it means
In getRefOverHTTP(), if the hosted-git service's refs response does not match any of the expected git protocol formats (smart HTTP, dumb HTTP, etc.), Yarn cannot extract a commit ref and throws as a terminal fallback.
Source
Thrown at src/resolvers/exotics/hosted-git-resolver.js:121
queue: this.resolver.fetchingQueue,
});
if (out) {
// clean up output
let lines = out.trim().split('\n');
// remove first two lines which contains compatibility info etc
lines = lines.slice(2);
// remove last line which contains the terminator "0000"
lines.pop();
// remove line lengths from start of each line
lines = lines.map((line): string => line.slice(4));
out = lines.join('\n');
} else {
throw new Error(this.reporter.lang('hostedGitResolveError'));
}
return client.setRefHosted(out);
}
async resolveOverHTTP(url: string): Promise<Manifest> {
const commit = await this.getRefOverHTTP(url);
const {config} = this;
const tarballUrl = this.constructor.getTarballUrl(this.exploded, commit);
const tryRegistry = async (registry): Promise<?Manifest> => {
const {filename} = registries[registry];
const href = this.constructor.getHTTPFileUrl(this.exploded, filename, commit);
const file = await config.requestManager.request({
url: href,
queue: this.resolver.fetchingQueue,View on GitHub (pinned to c2dda503f3)
Solutions
- Switch the dependency to a direct git+https:// or https:// URL
- Pin to a specific commit using #<full-hash> to bypass ref discovery
- Verify the git host is reachable and returns standard git refs
- Check for corporate proxies intercepting the refs request
Example fix
// before "my-dep": "bitbucket:user/repo" // after "my-dep": "git+https://bitbucket.org/user/repo.git#abc123"
Defensive patterns
Strategy: fallback
Validate before calling
// Prefer a pinned commit to avoid ref discovery entirely
function shouldPinCommit(pattern: string): boolean {
return /#[0-9a-f]{40}$/.test(pattern);
} Type guard
function isPinnableGitUrl(pattern: string): boolean {
return /git\+https?://.+#?[0-9a-f]{0,40}/.test(pattern);
} Try / catch
try {
const ref = await resolver.getRefOverHTTP(url);
} catch (e) {
if (e.message.includes('hostedGitResolveError')) {
// fall back to a git+https URL with a pinned commit
}
} Prevention
- Pin hosted-git dependencies to a specific commit hash
- Use git+https:// URLs for non-GitHub hosts
- Verify corporate proxies do not alter git ref responses
When it happens
Trigger: Resolving a non-GitHub hosted-git dependency where the refs endpoint returns an unrecognized format. The else branch fires after all known format checks fail.
Common situations: Private or self-hosted git services with non-standard ref listing; git host API/version changes; proxies or CDNs altering the response body.
Related errors
- Couldn't find package $0 required by $1 on the $2 registry.
- Unexpected audit response (Invalid JSON): ${response}
- publishFail
- packageNotFoundRegistry
- Unknown fetcher for $0
AI-assisted analysis of yarnpkg/yarn@c2dda503f3 (2026-08-13).
Data as JSON: /api/errors/17ac477c84959b9a.
Report an issue: GitHub.