Skip to content

fix(build): preserve flutter-packages on incremental builds (--skip-site-packages)#6634

Merged
FeodorFitsner merged 1 commit into
flet-0.86from
fix/incremental-build-wipes-flutter-extensions
Jul 2, 2026
Merged

fix(build): preserve flutter-packages on incremental builds (--skip-site-packages)#6634
FeodorFitsner merged 1 commit into
flet-0.86from
fix/incremental-build-wipes-flutter-extensions

Conversation

@FeodorFitsner

@FeodorFitsner FeodorFitsner commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Running flet build web a second time (without deleting build/) fails at dart2wasm:

Error: Couldn't resolve the package 'audioplayers_web' ...
Error: Couldn't resolve the package 'camera_web' ...
Error: Couldn't resolve the package 'webview_flutter_web' ...
Target dart2wasm failed: ProcessException: Process exited abnormally with exit code 254

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-packages to serious_python. That flag makes serious_python skip both the site-packages install and the "Copying Flutter packages to …/flutter-packages-temp" step — so flutter-packages-temp is never created that run.

register_flutter_extensions() then unconditionally rmtrees the permanent build/flutter-packages dir (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 rmtree was written assuming "temp dir absent ⟹ app has no extensions." --skip-site-packages broke that assumption: an absent temp dir now also means "extensions unchanged."

Regression

This is a regression from #6608. Before that PR the rmtree was nested inside if flutter_packages_temp_dir.exists():, so a skip build preserved the permanent copy. #6608 hoisted the rmtree out 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

  • Back-to-back flet build web (no rm -rf build) now completes on the second run instead of failing at dart2wasm.

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:

  • Fix incremental Flutter web builds failing at dart2wasm due to missing flutter-packages when running with --skip-site-packages.

Enhancements:

  • Track whether the packaging step skipped site-packages to preserve existing Flutter extension packages across incremental builds.

…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.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@FeodorFitsner FeodorFitsner merged commit ff08962 into flet-0.86 Jul 2, 2026
32 of 179 checks passed
@FeodorFitsner FeodorFitsner deleted the fix/incremental-build-wipes-flutter-extensions branch July 2, 2026 19:29
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.

1 participant