Skip to content

Bzlmod: vendor mode #19563

Closed
Closed

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

Activity

  1. added
    P1I'll work on this now. (Assignee required)
    team-ExternalDepsExternal dependency handling, remote repositiories, WORKSPACE file.
    area-BzlmodBzlmod-specific PRs, issues, and feature requests
    on Sep 19, 2023
  2. moved this from Todo to In Progress in Bzlmodon Oct 19, 2023
  3. 26 remaining items

  4. peakschris commented on May 8, 2024

    @peakschris
    Contributor

    @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

  5. Wyverald commented on May 15, 2024

    @Wyverald
    Member

    @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

  6. self-assigned this
    on Jul 17, 2024
  7. meteorcloudy commented on Aug 13, 2024

    @meteorcloudy
    Member
  8. moved this from In Progress to Done in Bzlmodon Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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