Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

archive_override() and git_override() should allow for same arguments as their repository rule counterparts #24412

Closed
jortega0 opened this issue Nov 20, 2024 · 2 comments
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug untriaged

Comments

@jortega0
Copy link

Description of the bug:

Currently, one cannot use all attributes with archive_override() that you can with http_archive(), which prevents some ability of using the module extension with things like the Github API to download archives.

We should probably make sure that archive_override() is sync'ed with http_archive or make archive_override() forward kwargs to http_archive().

The example case I'm running into is wanting to use the github api to download an archive, which does not include a filename extension, it has the form: https://api.github.com/repos/<org>/<repo>/tarball/<commit>

It is possible to be used with http_archive() by also providing the type attribute, but archive_override() does not allow for this attribute.

Which category does this issue belong to?

External Dependency

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Try to use archive_override() with the github api:

bazel_dep(name = "yaml-cpp", version = "0.0.0")
archive_override(
    module_name = "yaml-cpp",
    strip_prefix = "yaml-cpp-9ce5a25188d83b43dd5cd633f2975be10f5d6608",
    urls = ["https://api.github.com/repos/jbeder/yaml-cpp/tarball/9ce5a25188d83b43dd5cd633f2975be10f5d6608"],
)

Then use something like query to try to download the archive, eg.:

 bazel query @yaml-cpp//:all

Which operating system are you running Bazel on?

Ubuntu 22.04

What is the output of bazel info release?

release 7.4.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

I asked the question on the bazel slack workspace here: https://bazelbuild.slack.com/archives/C014RARENH0/p1731963696305899

Where it was indicated that similar reports of discrepancies were reported for the git_repository() extension as well. So it would be good to have a way to keep the rules and extensions in sync.

@github-actions github-actions bot added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Nov 20, 2024
@Wyverald
Copy link
Member

@bazel-io fork 8.0.0

Wyverald added a commit that referenced this issue Nov 21, 2024
So this kind of ran away from me...

* The motivator for this PR was to allow any `http_archive` attributes to be specified on `archive_override`. It was kind of a design oversight that we didn't allow this, to be honest; we've slowly accumulated fixes like adding `init_gitsubmodules` to `git_override`, adding `patch_cmds` to `archive_override`, etc., but the better alternative is to just forward all kwargs to the actual underlying repo rule.
* This somehow led to a big refactor where I remove the various `NonRegistryOverride` impls in favor of a simple wrapper around a `RepoSpec`, which led to the creation of a `RepoRuleId` class, which led to a refactor in BzlmodRepoRuleFunction (which also now houses the previous logic to validate labels in `ModuleFileGlobals`).
* Also includes some random Java 21 fixes that I couldn't resist... (`ModuleOverride` is now a sealed interface; added several switch expressions)

RELNOTES: `archive_override` now accepts all attributes usable with `http_archive`; similar for `git_override` and `git_repository`.

Fixes #24412

Closes #24378.

PiperOrigin-RevId: 698515353
Change-Id: I285c382d10ef228d46a1f1d732daa77a21bf890b
@iancha1992
Copy link
Member

A fix for this issue has been included in Bazel 8.0.0 RC3. Please test out the release candidate and report any issues as soon as possible.
If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=8.0.0rc3. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug untriaged
Projects
None yet
Development

No branches or pull requests

5 participants