Skip to content

Running flutter tests on linux might require clang and lld even if the app does not target linux since 3.38 #178715

@slaci

Description

@slaci

Steps to reproduce

With flutter 3.38.1 installed:

  1. flutter create --platforms=ios,android testproj
  2. cd testproj
  3. flutter pub add sqlite3:3.0.1
  4. flutter test

I'm doing this in a docker image from an M2 Mac: docker run --rm -it ghcr.io/cirruslabs/flutter:3.38.1 /bin/bash. This image does not have clang + lld installed. If I install those packages by apt install clang lld then the tests run, but I don't see why they are needed. Flutter doctor says these are needed for linux development, but the project does not target linux. As you can see it is enough to install a package which has a native asset hook, you don't have to use it in the code. I assume flutter wants to compile the native assets because the detected platform is linux as it is a linux container.

Expected results

The test provided by flutter create runs.

Actual results

Error:

Failed to find clang++ on PATH.

Code sample

Code sample

No code change is required. Adding the plugin is enough.

Screenshots or Video

Logs

Logs
[  +27 ms] "flutter test" took 167ms.
[   +4 ms] Failed to find clang++ on PATH.
[        ] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:34:3)
           #1      cCompilerConfigLinux (package:flutter_tools/src/isolated/native_assets/linux/native_assets.dart:28:5)
           <asynchronous suspension>
           #2      LinuxAssetTarget.setCCompilerConfig (package:flutter_tools/src/isolated/native_assets/targets.dart:234:68)
           <asynchronous suspension>
           #3      runFlutterSpecificHooks (package:flutter_tools/src/isolated/native_assets/native_assets.dart:82:5)
           <asynchronous suspension>
           #4      testCompilerBuildNativeAssets (package:flutter_tools/src/isolated/native_assets/test/native_assets.dart:70:42)
           <asynchronous suspension>
           #5      TestCommand.runCommand (package:flutter_tools/src/commands/test.dart:471:11)
           <asynchronous suspension>
           #6      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1559:27)
           <asynchronous suspension>
           #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
           <asynchronous suspension>
           #8      CommandRunner.runCommand (package:args/command_runner.dart:212:13)
           <asynchronous suspension>
           #9      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:487:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
           <asynchronous suspension>
           #11     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:422:5)
           <asynchronous suspension>
           #12     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:101:11)
           <asynchronous suspension>
           #13     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:154:19)
           <asynchronous suspension>
           #14     main (package:flutter_tools/executable.dart:103:3)
           <asynchronous suspension>
           
           
[        ] Running 1 shutdown hook
[        ] Shutdown hooks complete
[        ] exiting with code 1

Flutter Doctor output

Doctor output
[!] Flutter (Channel [user-branch], 3.38.1, on Ubuntu 24.04.1 LTS 6.10.14-linuxkit, locale en_US.UTF-8)
    ! Flutter version 3.38.1 on channel [user-branch] at /sdks/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    ✗ Flutter requires Android SDK 36 and the Android BuildTools 28.0.3
      To update the Android SDK visit https://flutter.dev/to/linux-android-setup for detailed instructions.
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✗] Linux toolchain - develop for Linux desktop
    ✗ clang++ is required for Linux development.
      It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/
    ✗ CMake is required for Linux development.
      It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from https://cmake.org/download/
    ✗ ninja is required for Linux development.
      It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases
    ✗ pkg-config is required for Linux development.
      It is likely available from your distribution (e.g.: apt install pkg-config), or can be downloaded from https://www.freedesktop.org/wiki/Software/pkg-config/
[☠] Connected device (the doctor check crashed)
    ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at
      https://github.com/flutter/flutter/issues.
    ✗ Error: Unable to run "adb", check your Android SDK installation and ANDROID_HOME environment variable: /opt/android-sdk-linux/platform-tools/adb
      Error details: Process exited abnormally with exit code -5:
      rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2
[✓] Network resources

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: buildBuilding flutter applications with the toola: tests"flutter test", flutter_test, or one of our testsc: crashStack traces logged to the consolefyi-linuxFor the attention of the Linux platform teamplatform-linuxBuilding on or for Linux specificallyr: fixedIssue is closed as already fixed in a newer versionteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions