You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
linux cmake does not report names of missing packages #115378
When running "flutter run" on linux, cmake might not find required packages but it doesn't report the name of the missing packages. The output also doesn't have a full path to the appropriate cmake file so it can be looked up. The cmake file has to be hunted down.
error log:
clarkeaa@gamer:~/dev/flutter-examples/counter$ flutter run
Launching lib/main.dart on Linux in debug mode...
CMake Error at /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:603 (message):
A required package was not found
Call Stack (most recent call first):
/usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:825 (_pkg_check_modules_internal)
flutter/CMakeLists.txt:25 (pkg_check_modules)
Building Linux application...
Exception: Unable to generate build files
Reacted by Jonas Wanke, Alfred, Kusha Gharahi, Hernán Manuel, Muhammad Umar and Spencer Riddering
The error comes from CMake, so we would need to add a regex to catch this, parse out the path and line, and then look it up within the tool and parse out the package on that line to provide our own error message with the package name.
I think bare minimum we should print the path to the cmakelists.txt if we know it. The error is printing out flutter/CMakeLists.txt but if I recall correctly we should be printing out ./build/<maybe something else here?>/flutter/CMakeLists.txt.
I think bare minimum we should print the path to the cmakelists.txt if we know it.
That would still require the regex and parsing, since that error message isn't coming from flutter. At that point the added read/parse to get the package name isn't much more work so I'm not sure why we wouldn't do it.
The error is printing out flutter/CMakeLists.txt but if I recall correctly we should be printing out ./build/<maybe something else here?>/flutter/CMakeLists.txt.
The path it's printing is relative to the CMake project root, which is linux/; the CMake file here is ./linux/flutter/CMakeLists.txt.
(Does flutter doctor actually pass for you? Unless you've modified that file, the failing package config lookup is to a library we should be validating in doctor.)
Nope i didn't modify it. The missing package was libgtk-3-0. In my case I was running ubuntu through the windows linux subsystem so gtk isn't installed by default. I imagine the same problem would happen if you are trying to use flutter from KDE. Although the likelihood of flutter being the first time you ran into this isn't the most probable.
edit: to be clear, flutter doctor passes if you don't have gtk3
Unfortunately I didn't capture "flutter doctor" results when filing this issue and the state of my machine has changed so I can't verify. It's likely I did a "flutter doctor" after I resolved this issue and I'm misremembering since nothing is printed if it passes.
If it does work correctly, we could potentially suggest running "flutter doctor" in the error case. That would be an improvement although probably not as good as reporting the dependency's name directly.
If it does work correctly, we could potentially suggest running "flutter doctor" in the error case.
That would only help for the case where someone gets this because they haven't run flutter doctor before trying to build for the very first time though. The more common way for someone to see a FindPkgConfig error is by using a plugin that has a library requirement that they haven't installed. (Or downloading an app project they didn't create, which has added more dependencies in its CMake file.)
Which gets back to my point above that if we're going to go to the trouble of building the structure necessary to catch this category of error and provide an additional message for it, we should do what I would expect to be a relatively small amount of extra work to make it generally useful.
Activity
stuartmorgan-g commentedon Nov 15, 2022
The error comes from CMake, so we would need to add a regex to catch this, parse out the path and line, and then look it up within the tool and parse out the package on that line to provide our own error message with the package name.
gaaclarke commentedon Nov 15, 2022
I think bare minimum we should print the path to the cmakelists.txt if we know it. The error is printing out
flutter/CMakeLists.txtbut if I recall correctly we should be printing out./build/<maybe something else here?>/flutter/CMakeLists.txt.stuartmorgan-g commentedon Nov 15, 2022
That would still require the regex and parsing, since that error message isn't coming from
flutter. At that point the added read/parse to get the package name isn't much more work so I'm not sure why we wouldn't do it.The path it's printing is relative to the CMake project root, which is
linux/; the CMake file here is./linux/flutter/CMakeLists.txt.(Does
flutter doctoractually pass for you? Unless you've modified that file, the failing package config lookup is to a library we should be validating indoctor.)gaaclarke commentedon Nov 15, 2022
Nope i didn't modify it. The missing package was
libgtk-3-0. In my case I was running ubuntu through the windows linux subsystem so gtk isn't installed by default. I imagine the same problem would happen if you are trying to use flutter from KDE. Although the likelihood of flutter being the first time you ran into this isn't the most probable.edit: to be clear, flutter doctor passes if you don't have gtk3
stuartmorgan-g commentedon Nov 15, 2022
It absolutely shouldn't:
flutter/packages/flutter_tools/lib/src/linux/linux_doctor.dart
Lines 54 to 58 in a866f3a
flutter/packages/flutter_tools/lib/src/linux/linux_doctor.dart
Lines 145 to 155 in a866f3a
Is
pkg-config --existsreturning bogus information in WSL?gaaclarke commentedon Nov 15, 2022
Unfortunately I didn't capture "flutter doctor" results when filing this issue and the state of my machine has changed so I can't verify. It's likely I did a "flutter doctor" after I resolved this issue and I'm misremembering since nothing is printed if it passes.
If it does work correctly, we could potentially suggest running "flutter doctor" in the error case. That would be an improvement although probably not as good as reporting the dependency's name directly.
stuartmorgan-g commentedon Nov 16, 2022
That would only help for the case where someone gets this because they haven't run
flutter doctorbefore trying to build for the very first time though. The more common way for someone to see a FindPkgConfig error is by using a plugin that has a library requirement that they haven't installed. (Or downloading an app project they didn't create, which has added more dependencies in its CMake file.)Which gets back to my point above that if we're going to go to the trouble of building the structure necessary to catch this category of error and provide an additional message for it, we should do what I would expect to be a relatively small amount of extra work to make it generally useful.
flutter-triage-bot commentedon Jun 6, 2024
The
triaged-desktoplabel is irrelevant if there is noteam-desktoplabel orfyi-desktoplabel.