feat(pub): declare pub_deps.json reports with pub.from_file - #18
Merged
Merged
Conversation
The pub extension scans the root module for pub_deps.json and watches the listing of every directory it visits. On Bazel 9.2 a watched directory that is deleted fails every pub repository with "is no longer an existing directory" until `bazel clean --expunge` (bazelbuild/bazel#30883). The stale listing lives in the output base's hidden lockfile, so a server restart does not clear it, and CI runners that reuse an output base across branches hit it whenever the next branch lacks a directory the previous one had. pub.from_file(pub_deps = label) reads exactly the declared reports and watches only those files. Declaring any report replaces the scan; without the tag the scan runs as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The
pubextension findspub_deps.jsonfiles by scanning the root module, and it watches the listing of every directory it reads. On Bazel 9.2, if one of those directories is later deleted, revalidating the extension fails every pub repository with "is no longer an existing directory" (bazelbuild/bazel#30883). The fix (bazelbuild/bazel#31022) ships in 9.3.0, which is still a release candidate. The stale listing lives in the output base's hidden lockfile ($(output_base)/MODULE.bazel.lock), so a server restart does not clear it. Onlybazel clean --expungedoes.CI runners that reuse an output base across branches hit this whenever the next branch lacks a directory the previous one had. Re-running on the same runner keeps failing.
This adds
pub.from_file(pub_deps = "//app:pub_deps.json"). Declaring any report replaces the scan: the extension reads exactly the declared reports and watches only those files, so adding or deleting directories can neither fail nor rerun it. Without the tag, the scan runs as before.Adding the tag also recovers a workspace that already hit the error. The changed usages make Bazel rerun the extension instead of revalidating the stale listings (under the default
--lockfile_mode=update).test_declaring_reports_recovers_from_deleted_directory_on_bazel_9_2covers this.The two
MODULE.bazel.lockchanges are theflutterextension'sbzlTransitiveDigest, which followsextensions.bzl.Checklist
bazel test //flutter/tests:all_tests //docs:update_testspasses (28/28 on macOS arm64, Bazel 9.2.0)cd e2e/smoke && bazel test //:integration_testspasses (if behavior changed): 24/24 on macOS arm64.//:pub_extension_testruns 7/7 including the two new cases, and both new cases fail if the extension ignores the tag. The first run hit an unrelated flake (a transient git object vanished from the macOS Flutter SDK repository's.gitwhile//flutter_app:lib_formatbuilt); a rerun passed.bazel run //docs:update(regeneratesdocs/extensions.md)pre-commit run --all-files(buildifier + prettier) is clean: pre-commit is not installed here. I ran the equivalents instead.buildifier --mode=check --lint=warn flutter/extensions.bzlis clean apart from the two existingcanonical-repositorywarnings in_module_root, and prettier 3.1.0--checkpasses onREADME.mdandCHANGELOG.md(docs/*.mdis prettier-ignored).docs/migrating.md,docs/hermeticity.md, CHANGELOG)🤖 Generated with Claude Code