-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
MODULE.bazel.lock file "reads through" already-locked package manager #20272
Comments
Proposal: there should be an API for |
The key action item here is to do exactly this -- in other words, allow a module extension to say "I don't want to be locked" in some manner. I've discussed this topic with the rules_python maintainers in some depth, with some more sophisticated ideas thrown around, but this is the first step. The only question to address here would be whether we want this to be a per-extension setting (the extension is either always locked or never locked, à la |
Thanks! FWIW I don't have a preference between those two methods of "opting out" of having the extension results be locked. I could imagine there might be "custom lockfile content" issues with |
I find it important to consider these two different benefits of the lockfile separately:
Even when module extensions such as those provided by rules_js and rules_go are already reproducible in the sense that their lockfile representation does not contain any information that isn't already a pure function of the extension tags, file deps and implementation function, they may still benefit from 2. In particular in the case of rules_js this is noticeable since it has to parse a potentially large yaml file in Starlark, which can take on the order of 10 seconds for large projects. Ideally, a solution to this issue would resolve this duplication while still maintaining the performance benefit of the lockfile. My idea is a combination of two features that actually share a lot of their implementation complexity:
Both of these features require generalizing the Java (not the JSON) representation of the lockfile to an (ordered) list of lockfiles. I prototyped this and found it to add a modest amount of complexity - it even makes some parts of the existing code cleaner and error messages more precise (e.g. the handling of a missing lockfile).
I also think that there is no reason to not make this decision per-evaluation. We already have the API for this in the form of
I haven't been able to come up with an example of an extension that would rightfully want to say "I don't want to be locked", but isn't reproducible. Knowing that the extension is reproducible allows further optimizations as described above, so I would find this bit safer to add than a catch-all |
Can we teach Dependabot to run (sorry for the unintended close, keyboard shortcuts can be dangerous) |
@bazel-io fork 7.1.0 |
@dzbarsky observed another more serious consequence of this, is that an auth token for your private npm registry will leak into the lockfile as well. I imagine the same could be true for other package managers. |
@alexeagle Can you explain more how/where would this token appear in the lockfile? |
@SalmaSamy yup, looks like that's here https://github.com/aspect-build/rules_js/blob/d4f2068adc2b97c3c97fdf588a765562591f410e/npm/extensions.bzl#L125 |
Note @fmeum I blogged about using the git merge driver feature to make the lockfile update less annoying: https://blog.aspect.dev/easier-merges-on-lockfiles I can't tell if your feature of having |
@alexeagle I plan to write the design doc this week. In the meantime, the custom merge driver is a decent workaround. |
@alexeagle I attached a PR to fix this, but @fmeum has a different idea that we're discussing. Do you think this is an urgent fix for 7.1.0? or we can wait to find the most suitable solution? |
… the lockfile (fixes #20272) Adding 'reproducible' to the module extension metadata PiperOrigin-RevId: 606288112 Change-Id: Ieca9c5eeb560e3556ba2b7e3f0a29c362bfa4f4b # Conflicts: # src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionContext.java # src/main/java/com/google/devtools/build/lib/bazel/bzlmod/ModuleExtensionMetadata.java
A fix for this issue has been included in Bazel 7.1.0 RC1. Please test out the release candidate and report any issues as soon as possible. Thanks! |
Description of the bug:
MODULE.bazel.lock repeats content from package manager lockfiles, leading to serious developer experience regressions.
Desired behavior
As an example, in https://github.com/bazelbuild/examples/tree/611827d1bacfe83408cba2bbdcca4a801687d814/frontend
Bazel (via
npm_translate_lock
) starts frompnpm-lock.yaml
[1] which fully specifies all the fields (URL, integrity) needed forrctx.download
calls in rules_js.When developers have a merge conflict in that file, they can just run the install again, because the tool is aware of git merge conflict markers. https://pnpm.io/git#merge-conflicts (the same is true for npm and yarn, the other popular JS package managers)
Also, when tooling like Dependabot updates their dependency versions, the lockfile is updated as well.
So, when the lockfile is updated, I would expect this entry in the
MODULE.bazel.lock
file to be trivially updated:Actual behavior
However, when upgrading that repo to Bazel 7.0, we now get a MASSIVE Bazel lockfile, much larger than the original:
Of these lines, nearly all are in this block:
Any merge conflicts in this file will present the developer with a massive headache, and they'll likely just delete-and-recreate the lockfile to get past it. Of course that's a bad practice as you've accidentally lost the pinning of all other Bazel modules.
Also, PRs from Dependabot will cause Bazel's lockfile to be out-of-date. Dependabot PRs are commonly security-related, so engineers have a great sense of urgency in merging them, and will again just work around the Bazel lockfile checking on CI or disable the feature.
[1] https://github.com/bazelbuild/examples/blob/main/frontend/pnpm-lock.yaml
Which category does this issue belong to?
External Dependency
What is the output of
bazel info release
?7.0.0rc4
The text was updated successfully, but these errors were encountered: