yarnpkg/yarn · error · MessageError

couldntFindMatch

Error message

couldntFindMatch

What it means

Error "couldntFindMatch" thrown in yarnpkg/yarn.

Solutions

  1. The requested commit, tag, branch, or semver range could not be resolved to any ref in the git repository. Check the fragment after the # in the dependency URL for typos.
  2. Run `git ls-remote <repo-url>` and pick one of the listed refs or a valid 40-char commit sha, then update package.json.
  3. If the commit exists locally but not on the remote, push it to the remote repository first.

Example fix

git ls-remote https://github.com/user/repo.git | grep <ref>  # then fix the #<ref> in package.json

When it happens

Trigger: Yarn cannot find a git ref, branch, or tag matching the requested commit-ish in src/util/git.js.

Common situations: Occurs when a package.json git dependency references a non-existent branch, tag, or commit, or the remote no longer advertises the ref.


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

Appendix: source

Thrown at src/util/git.js:502

  }

  /**
   * Resolves the input hash / ref / semver range to a valid commit sha
   * If possible also resolves the sha to a valid ref in order to use "git archive"
   */

  async setRef(refs: GitRefs): Promise<string> {
    // get commit ref
    const {hash: version} = this;

    const resolvedResult = await resolveVersion({
      config: this.config,
      git: this,
      version,
      refs,
    });
    if (!resolvedResult) {
      throw new MessageError(
        this.reporter.lang('couldntFindMatch', version, Array.from(refs.keys()).join(','), this.gitUrl.repository),
      );
    }

    this.hash = resolvedResult.sha;
    this.ref = resolvedResult.ref || '';
    return this.hash;
  }
}

View on GitHub (pinned to c2dda503f3)