bazel
bazel copied to clipboard
Bzlmod: vendor mode
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
@bazel-io fork 7.1.0
Is vendor mode supposed to include everything for an airgapped build? Because I'm using it with 7.1.1 and I'm finding a lot of repositories are not being included in vendor_dir. It is not clear to me from the design doc what the UI should be for creating a vendor_dir, and for building with it. And I'm not clear what parts are now implemented and tested and what is coming. Thanks for any clarity!
@Wyverald I'm seeing issues with vendoring rules_helm (using release-7.2.0 latest). This module contains a symlink to a sub-repo, and the vendored symlink still points into the user cache, whilst I'd expect it to be rewritten to symlink into the vendor dir. Is this a known issue or should I open a new issue?
https://gitlab.industrysoftware.automation.siemens.com/devx/vendor/rules_helm/-/blame/main/helm/repositories.bzl#L130
@peakschris thanks for testing it out! Please file new issues for the symlink thing -- we're aware of it, but it's still nice to keep track of it explicitly.
EDIT:
Is vendor mode supposed to include everything for an airgapped build?
It should be. If it's missing, it's definitely something we should address at some point, so please feel free to file an issue
Vendor mode is shipped with https://github.com/bazelbuild/bazel/releases/tag/7.3.0