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

Switch to bzlmod #1294

Merged
merged 1 commit into from
Jan 3, 2024
Merged

Switch to bzlmod #1294

merged 1 commit into from
Jan 3, 2024

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Dec 13, 2023

This works for bazel build ....

I have not yet gotten bazel run //third-party:vendor working.

bazelbuild/rules_rust#1493 #1095

@dtolnay dtolnay marked this pull request as draft December 13, 2023 07:36
@dtolnay dtolnay force-pushed the bzlmod branch 3 times, most recently from e56b914 to f4f6899 Compare December 28, 2023 16:57
@dtolnay
Copy link
Owner Author

dtolnay commented Dec 28, 2023

bazel run //third-party:vendor requires bazelbuild/rules_rust#2372.

illicitonion pushed a commit to bazelbuild/rules_rust that referenced this pull request Dec 28, 2023
Without this, I have been unable to update
https://github.com/dtolnay/cxx to bzlmod. When I run `bazel run
//third-party:vendor` ([this
rule](https://github.com/dtolnay/cxx/blob/3c1bcc012f285dc59d39143e658df67659142cd1/third-party/BUILD#L3-L11))
it failed with **"unknown repo 'cargo_bazel.buildifier-linux-amd64'
requested from @@rules_rust~0.35.0"**:

```console
ERROR: no such package '@@[unknown repo 'cargo_bazel.buildifier-linux-amd64' requested from @@rules_rust~0.35.0]//file': The repository '@@[unknown repo 'cargo_bazel.buildifier-linux-amd64' requested from @@rules_rust~0.35.0]' could not be resolved: No repository visible as '@cargo_bazel.buildifier-linux-amd64' from repository '@@rules_rust~0.35.0'
ERROR: ~/.cache/bazel/_bazel_david/ebce1d0721fb68dda9c70c0dd1405803/external/rules_rust~0.35.0/crate_universe/private/vendor/BUILD.bazel:3:27: no such package '@@[unknown repo 'cargo_bazel.buildifier-linux-amd64' requested from @@rules_rust~0.35.0]//file': The repository '@@[unknown repo 'cargo_bazel.buildifier-linux-amd64' requested from @@rules_rust~0.35.0]' could not be resolved: No repository visible as '@cargo_bazel.buildifier-linux-amd64' from repository '@@rules_rust~0.35.0' and referenced by '@@rules_rust~0.35.0//crate_universe/private/vendor:buildifier'
ERROR: Analysis of target '//third-party:vendor' failed; build aborted: Analysis failed
```

After this change, it works. My MODULE.bazel can be seen in
dtolnay/cxx#1294.
@dtolnay dtolnay force-pushed the bzlmod branch 2 times, most recently from 06804e2 to 4edfc32 Compare January 2, 2024 23:58
@dtolnay dtolnay marked this pull request as ready for review January 3, 2024 01:32
@dtolnay dtolnay merged commit f0fa65a into master Jan 3, 2024
29 checks passed
@dtolnay dtolnay deleted the bzlmod branch January 3, 2024 01:32
illicitonion pushed a commit to bazelbuild/rules_rust that referenced this pull request Jan 3, 2024
`integrity` is preferred because it works for both `http_archive`
(legacy) and `archive_override` (bzlmod). `sha256` only works for
`http_archive`. Context: bazelbuild/bazel#20156

I confirmed that `xxd` and `base64` commands are available in the GitHub
ubuntu-20.04 runner:

![Screenshot from 2024-01-02
17-24-23](https://github.com/bazelbuild/rules_rust/assets/1940490/a30e58c4-fd78-4c37-969d-1938b2dc2215)

and that this produces an integrity string that checks out with what
Bazel wants. See
dtolnay/cxx@17f46ec
for a successful use of `integrity` with `http_archive`:

```starlark
# WORKSPACE.bazel

http_archive(
    name = "rules_rust",
    integrity = "sha256-p2HVTknbBvhjRo5rukoTJSsb1Jno9wbaZeJ5s7y8XFI=",
    urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.36.2/rules_rust-v0.36.2.tar.gz"],
)
```

and dtolnay/cxx#1294 for a successful use of
`integrity` with `archive_override`.

```starlark
# MODULE.bazel

archive_override(
    module_name = "rules_rust",
    integrity = "sha256-p2HVTknbBvhjRo5rukoTJSsb1Jno9wbaZeJ5s7y8XFI=",
    urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.36.2/rules_rust-v0.36.2.tar.gz"],
)
```

`sha256` does not work in `archive_override`.

```console
ERROR: Traceback (most recent call last):
	File "/git/cxx/MODULE.bazel", line 5, column 17, in <toplevel>
		archive_override(
Error in archive_override: archive_override() got unexpected keyword argument 'sha256'
ERROR: Error computing the main repository mapping: error executing MODULE.bazel file for <root>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant