Skip to content

Conversation

hofbi
Copy link
Contributor

@hofbi hofbi commented Jun 12, 2025

I did some experiments on this example to evaluate the lockfile attribute vs. using MODULE.bazel.lock:

I ran bazel test //... --profile=.... After every run, I did a bazel clean && bazel shutdown to start clean.

  1. Run (MODULE.bazel.lock file only): No cargo-bazel call found in the profile generated
  2. Run (add the lockfile, run CARGO_BAZEL_REPIN=true bazel mod tidy, then bazel test): No cargo-bazel call found in the profile generated
  3. Run (delete MODULE.bazel.lock): cargo-bazel was called, but cargo splicing was very fast. The MODULE.bazel.lock was recreated
  4. Run (deleteMODULE.bazel.lock and run with --lockfile_mode=off): cargo-bazel was called, similar to above

This suggests:

  • If you have the MODULE.bazel.lock file up to date, no cargo-bazel is called regardless of using the lockfile or not
  • If the MODULE.bazel.lock is not tracked in VCS the lockfile seems to be helpful and should be used
  • Comparing the MODULE.bazel.lock file and the lockfile a bit more in detail, shows they store similar information. The lockfile is a bit more well structured json (for the rust specific content) while the MODULE.bazel.lock file seems to store the entire content generated for every crate in a single string.

Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

Thanks!

@illicitonion illicitonion added this pull request to the merge queue Jun 12, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 12, 2025
@illicitonion illicitonion added this pull request to the merge queue Jun 12, 2025
Merged via the queue into bazelbuild:main with commit 0cb272d Jun 13, 2025
3 checks passed
Synss pushed a commit to Synss/rules_rust that referenced this pull request Jun 13, 2025
I did some experiments on [this
example](https://github.com/bazelbuild/rules_rust/blob/e38fa8c2bc0990debceaf28daa4fcb2c57dcdc1c/examples/hello_world/MODULE.bazel#L25-L30)
to evaluate the `lockfile` attribute vs. using `MODULE.bazel.lock`:

I ran `bazel test //... --profile=...`. After every run, I did a `bazel
clean && bazel shutdown` to start clean.

1. Run (`MODULE.bazel.lock` file only): No `cargo-bazel` call found in
the profile generated
1. Run (add the `lockfile`, run `CARGO_BAZEL_REPIN=true bazel mod tidy`,
then `bazel test`): No `cargo-bazel` call found in the profile generated
1. Run (delete `MODULE.bazel.lock`): `cargo-bazel` was called, but cargo
splicing was very fast. The `MODULE.bazel.lock` was recreated
1. Run (delete`MODULE.bazel.lock` and run with `--lockfile_mode=off`):
`cargo-bazel` was called, similar to above

This suggests:

* If you have the `MODULE.bazel.lock` file up to date, no `cargo-bazel`
is called regardless of using the `lockfile` or not
* If the `MODULE.bazel.lock` is not tracked in VCS the `lockfile` seems
to be helpful and should be used
* Comparing the `MODULE.bazel.lock` file and the `lockfile` a bit more
in detail, shows they store similar information. The `lockfile` is a bit
more well structured json (for the rust specific content) while the
`MODULE.bazel.lock` file seems to store the entire content generated for
every crate in a single string.
@hofbi hofbi deleted the lockfile-recommendations branch July 30, 2025 09:21
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.

2 participants