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

  1. Switch the dependency to a direct git+https:// or https:// URL
  2. Pin to a specific commit using #<full-hash> to bypass ref discovery
  3. Verify the git host is reachable and returns standard git refs
  4. 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

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


AI-assisted analysis of yarnpkg/yarn@c2dda503f3 (2026-08-13). Data as JSON: /api/errors/17ac477c84959b9a. Report an issue: GitHub.