Skip to content

Bzlmod: vendor mode #19563

@SalmaSamy

Description

@SalmaSamy

Vendor command fetches all external repositories into a folder specified by the flag --vendor_dir.

For the initial vendoring or updating existing vendor repositories the new command is:
bazel vendor --vendor_dir={vendordir}
With this all dependencies will be fetched to the specified directory. Also a target/s can be passed to limit the dependencies or --repo={repo_name} can be used to vendor a specific repo

The {vendordir} parameter can be either a full path or just a folder name, then the vendored repositories will be located under {workspace}/{vendordir}.


To perform a build using the vendored repositories, the same flag & value should be used:
bazel build {target} --vendor_dir={vendordir}
In this scenario, the vendor directory will be prioritized for repository retrieval. If the repository is not found or is outdated, the standard process will be followed, which involves checking cached repositories and fetching if not found.

Build & vendored repo is out-of-date/ not found:

  • If fetch is enabled, the repo will be fetched and used with a warning that a re-vendor is needed to update it under the vendor directory
  • If fetch is disabled, the vendored repo will be used as it is with a warning that it is out-of-date, or fail if it is not found

VENDOR.bazel file
A Starlark config file to allow controlling the vendored repos via:

  • ignore('repo_name','repo_name', ....) function
    Bazel will never vendor the repo or consider the vendor directory while building in vendor mode.
  • pin('repo_name','repo_name', ....) function
    Bazel will pin the contents of this repo, will not update it while vendoring, and will always use it as is when building in vendor mode

In progress:

  • Documentation

Metadata

Metadata

Labels

P1I'll work on this now. (Assignee required)area-BzlmodBzlmod-specific PRs, issues, and feature requeststeam-ExternalDepsExternal dependency handling, remote repositiories, WORKSPACE file.type: feature request

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions