Skip to content

[stable] [flutter_tools] Fix native assets crash on Linux custom devices#189088

Merged
auto-submit[bot] merged 2 commits into
flutter:flutter-3.44-candidate.0from
bkonyi:cherry-pick-188384-to-stable
Jul 8, 2026
Merged

[stable] [flutter_tools] Fix native assets crash on Linux custom devices#189088
auto-submit[bot] merged 2 commits into
flutter:flutter-3.44-candidate.0from
bkonyi:cherry-pick-188384-to-stable

Conversation

@bkonyi

@bkonyi bkonyi commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.

Issue Link:

#187980

Impact Description:

When native assets are enabled on Linux, building asset bundles (e.g., flutter build bundle or running on custom devices without a native CMake build) crashes with a tool exit because CMakeCache.txt is missing.

Changelog Description:

flutter/187980: On Linux, building asset bundles with native assets enabled without a native app build directory crashes due to missing CMakeCache.txt.

Workaround:

None for custom devices or bundle builds where CMake is not executed.

Risk:

What is the risk level of this cherry-pick?

  • Low
  • Medium
  • High

Test Coverage:

Are you confident that your fix is well-tested by automated tests?

  • Yes
  • No

Validation Steps:

  1. Enable native assets on Linux (flutter config --enable-native-assets).
  2. Run flutter build bundle in a project with a native asset hook.
  3. Verify that flutter build bundle succeeds without crashing due to missing CMakeCache.txt.

…ter#188384)

When native assets are enabled, the Flutter tool attempts to resolve the
C compiler configuration. On Linux, this is done by reading
`CMakeCache.txt` from the native build directory to align toolchains.

However, for custom devices or `flutter build bundle` commands, no
native app build is performed, meaning `CMakeCache.txt` does not exist.
This previously caused the tool to crash unconditionally.

This PR:
1. Adds a `throwIfNotFound` parameter to `cCompilerConfigLinux`
(defaulting to `true`) to allow graceful failures (returning `null`)
when the CMake cache or toolchain is missing.
2. Updates `LinuxAssetTarget.setCCompilerConfig` to only require the
compiler configuration (passing `throwIfNotFound: true`) if a native app
build directory actually exists. Otherwise, it allows it to be optional
and return `null`.
3. Fixes and adds unit tests, and introduces a new integration test
verifying that `flutter build bundle` succeeds on Linux with native
assets.

Fixes flutter#187980
@bkonyi
bkonyi requested a review from a team as a code owner July 7, 2026 21:03
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jul 7, 2026
@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. a: desktop Running on desktop team-linux Owned by the Linux platform team labels Jul 7, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a throwIfNotFound parameter to cCompilerConfigLinux to allow returning null instead of throwing exceptions when compiler configurations or tools are missing, and updates LinuxAssetTarget and tests accordingly. The reviewer recommends documenting this new parameter to comply with the repository style guide.

@bkonyi bkonyi added the cp: review Cherry-picks in the review queue label Jul 7, 2026
@eyebrowsoffire eyebrowsoffire added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 8, 2026
@auto-submit
auto-submit Bot merged commit 4561c36 into flutter:flutter-3.44-candidate.0 Jul 8, 2026
151 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD cp: review Cherry-picks in the review queue team-linux Owned by the Linux platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants