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

Update rust toolchain to use rules_rust 0.22.0 #393

Merged
merged 6 commits into from
Aug 4, 2023

Conversation

contagnas
Copy link
Contributor

rules_rust 0.22.0 removes rust_toolchain.os in bazelbuild/rules_rust#1960

note this change isn't compatible with earlier versions of rules_rust, because the os field was required.

@contagnas contagnas requested a review from benradf as a code owner June 9, 2023 02:13
Copy link
Member

@aherrmann aherrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
Small comment about the version bump.

toolchains/rust/MODULE.bazel Outdated Show resolved Hide resolved
@benradf
Copy link
Member

benradf commented Jun 9, 2023

Thanks for the PR @contagnas!

It looks like CI is failing with this error:

ERROR: ... BUILD:66:15: @nixpkgs_config_rust//:rust_nix_impl: missing value for mandatory attribute 'os' in 'rust_toolchain' rule

Which is odd, if os has been removed in rules_rust 0.22.0. Maybe it's somehow still using the old version? I haven't had a chance to dig deeper yet.

@@ -1,6 +1,6 @@
{
"homepage": "https://bazelbuild.github.io/rules_rust/",
"maintainers": [],
"versions": ["0.17.0"],
"versions": ["0.22.0"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with bzlmod yet, so it's not clear to me if this registry should have multiple version of dependencies, or just the current one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This registry is only used for testing (see readme), so a single version is enough.

@@ -1,5 +1,5 @@
{
"url": "https://github.com/bazelbuild/rules_rust/releases/download/0.17.0/rules_rust-v0.17.0.tar.gz",
"url": "https://github.com/bazelbuild/rules_rust/releases/download/0.22.0/rules_rust-v0.22.0.tar.gz",
"integrity": "sha384-v3eVoRi4rdkELxzV3egjTJkc8M3UH1YmbdZ2m6Y45gpjBew4a/JU5A4TFNO8Bq3z",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expected this sha to need an update, but I can't find anything that uses it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bazel checks against this sha after downloading the dependency. I think it will also cache based on that sha, so if it's not updated you may get an old artifact.

@benradf
Copy link
Member

benradf commented Jun 14, 2023

A different CI error now 🤔

   ERROR: /home/runner/work/rules_nixpkgs/rules_nixpkgs/examples/toolchains/rust/WORKSPACE:112:18: fetching crates_repository rule //external:crate_index: Traceback (most recent call last):
  	File "/home/runner/.cache/bazel/_bazel_runner/962535b5b03441543344ad7194339468/external/rules_rust/crate_universe/private/crates_repository.bzl", line 45, column 28, in _crates_repository_impl
  		repin = determine_repin(
  	File "/home/runner/.cache/bazel/_bazel_runner/962535b5b03441543344ad7194339468/external/rules_rust/crate_universe/private/generate_utils.bzl", line 382, column 13, in determine_repin
  		fail(("\n".join([
  Error in fail: Digests do not match: Digest("59ace66e05f26b5ab71bdc99a930d8b1bafdb232f70f60ad13c15599bc4a49a4") != Digest("a287c27b9422cf61b5995ee3c56060decae072616e470f667c74d3bd1650e80f")
  
  The current `lockfile` is out of date for 'crate_index'. Please re-run bazel using `CARGO_BAZEL_REPIN=true` if this is expected and the lockfile should be updated.

@benradf
Copy link
Member

benradf commented Aug 4, 2023

The expected hash that gets printed when there's a mismatch is in hexadecimal, but the hash in source.json should be base64. So I had to do a conversion:

$ (xxd -r -p | base64) <<<f47303cd12b8b8ebfdce0e2ac93f2b72d1d484d7ef9bd6f3b4f307f523e331ebbf3496caed2688f4d5345918344be9f2
9HMDzRK4uOv9zg4qyT8rctHUhNfvm9bztPMH9SPjMeu/NJbK7SaI9NU0WRg0S+ny

@benradf
Copy link
Member

benradf commented Aug 4, 2023

Fixed the failure in examples/toolchains/rust by updating the lockfile:

CARGO_BAZEL_REPIN=true bazel run --config=nix :hello

@benradf benradf merged commit db8ad39 into tweag:master Aug 4, 2023
9 checks passed
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.

3 participants