MODULE.bazel.lock is diff-unfriendly for large crate universes

Open
#3,946 11 comments 2 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
38/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
build-system

Research direction

Start with MODULE.bazel.lock and the BUILD file content it embeds, then inspect the linked lockfile-opt proof of concept and compare its diff against main. Understand how the three crate universes are represented before refining the approach. Done means lockfile changes for one or two crates produce substantially smaller, reviewable diffs without breaking bzlmod behavior.

Written by the indexing model from the issue text.

Description

crate-universe

We recently transitioned to using bzlmod to manage our 3 rather large crate universes. It's working great, and I really like not having to worry about the individual lockfiles.

There's one problem: The MODULE.bazel.lock file has become huge; it takes about 2x the space that the original lockfiles did. But worse, it's very diff-unfriendly. It contains entire BUILD files, and changings one crate will cause the entire master BUILD file to change, resulting in a pages-long inscrutable diff. This makes it challenging to review changes that include crate universe modifications, and often overloads diff viewer tools.

I have put together a proof of concept that reduces the MODULE.bazel.lock size to be comparable to the old lockfiles it replaces, but more importantly, it removes the very long BUILD content lines, so that changes affecting only one or two crates don't change the MODULE.bazel.lock file so dramatically.

Proof of concept is here: https://github.com/bazelbuild/rules_rust/compare/main...jblebrun:rules_rust:lockfile-opt

I'm not ready to make a PR with this, since I got quite a bit of help from AI to generate it, and I want to fully understand what it's doing before expecting others to do the same.

But I figured I'd open this issue, in case anyone else is struggling with the issue as well, is exploring possible resolutions already, or is interested in helping to review and refine my proof-of-concept solution.

Dominant language
Starlark
Stars
857
Forks
701
Avg merge
4d 7h
Merged PRs (30d)
46

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_rust

All issues in bazelbuild/rules_rust

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.