fix(build): preserve flutter-packages on incremental builds (--skip-site-packages)#6634
Merged
FeodorFitsner merged 1 commit intoJul 2, 2026
Conversation
…ntal builds register_flutter_extensions() unconditionally wiped the permanent build/flutter-packages directory before repopulating it only when the temp dir exists. On incremental builds the package hash is unchanged, so serious_python is invoked with --skip-site-packages and does not copy Flutter packages to the temp dir. The absent temp dir then meant the wiped extensions were never restored, breaking 'flutter build web' (unresolved web plugins such as audioplayers_web, camera_web, etc.). Track when the package step ran with --skip-site-packages and skip the wipe/move in that case, keeping the previous build's extension copy. A removed extension changes the package requirements, flips the hash, and takes the full (non-skip) path that still clears stale extensions. Regression from #6608.
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.
Problem
Running
flet build weba second time (without deletingbuild/) fails atdart2wasm:The first build succeeds; the second (incremental) build fails. This hits the normal incremental workflow for any app that uses Flutter extensions.
Root cause
On an incremental build the package hash is unchanged, so
package_python_app()passes--skip-site-packagestoserious_python. That flag makes serious_python skip both the site-packages install and the "Copying Flutter packages to …/flutter-packages-temp" step — soflutter-packages-tempis never created that run.register_flutter_extensions()then unconditionallyrmtrees the permanentbuild/flutter-packagesdir (populated by the first build) and only repopulates it if the temp dir exists. Since the temp dir is absent on a skip build, the flet extension packages (flet_audio,flet_camera,flet_webview, …) are wiped and never restored, so the Flutter build can't resolve the web plugins they provide.The
rmtreewas written assuming "temp dir absent ⟹ app has no extensions."--skip-site-packagesbroke that assumption: an absent temp dir now also means "extensions unchanged."Regression
This is a regression from #6608. Before that PR the
rmtreewas nested insideif flutter_packages_temp_dir.exists():, so a skip build preserved the permanent copy. #6608 hoisted thermtreeout of the guard (to clear a removed extension lingering in the permanent dir) without accounting for the skip-site-packages path.Fix
Track when the package step ran with
--skip-site-packages(self.site_packages_skipped) and skip the wipe/move in that case, keeping the previous build's extension copy intact.This preserves #6608's removed-extension handling: dropping an extension changes the package requirements, which flips the package hash and takes the full (non-skip) path that still clears stale extensions.
Testing
flet build web(norm -rf build) now completes on the second run instead of failing atdart2wasm.Summary by Sourcery
Prevent incremental Flutter web builds from deleting and failing to restore previously copied Flutter extension packages when site-packages are skipped.
Bug Fixes:
Enhancements: