Skip to content

linux cmake does not report names of missing packages #115378

Open

Description

@gaaclarke

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

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    a: buildBuilding flutter applications with the tool
    on Nov 15, 2022
  2. stuartmorgan-g commented on Nov 15, 2022

    @stuartmorgan-g
    Contributor

    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.

  3. gaaclarke commented on Nov 15, 2022

    @gaaclarke
    MemberAuthor

    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.

  4. added
    P2Important issues not at the top of the work list
    on Nov 15, 2022
  5. stuartmorgan-g commented on Nov 15, 2022

    @stuartmorgan-g
    Contributor

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

  6. gaaclarke commented on Nov 15, 2022

    @gaaclarke
    MemberAuthor

    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

  7. stuartmorgan-g commented on Nov 15, 2022

    @stuartmorgan-g
    Contributor

    edit: to be clear, flutter doctor passes if you don't have gtk3

    It absolutely shouldn't:

    final List<String> _requiredGtkLibraries = <String>[
    'gtk+-3.0',
    'glib-2.0',
    'gio-2.0',
    ];

    bool libraryMissing = false;
    for (final String library in _requiredGtkLibraries) {
    if (!await _libraryIsPresent(library)) {
    libraryMissing = true;
    break;
    }
    }
    if (libraryMissing) {
    validationType = ValidationType.missing;
    messages.add(ValidationMessage.error(_userMessages.gtkLibrariesMissing));
    }

    Is pkg-config --exists returning bogus information in WSL?

  8. gaaclarke commented on Nov 15, 2022

    @gaaclarke
    MemberAuthor

    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.

  9. stuartmorgan-g commented on Nov 16, 2022

    @stuartmorgan-g
    Contributor

    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.

  10. added
    team-linuxOwned by the Linux platform team
    and removed on Jun 6, 2024
  11. flutter-triage-bot commented on Jun 6, 2024

    @flutter-triage-bot

    The triaged-desktop label is irrelevant if there is no team-desktop label or fyi-desktop label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: buildBuilding flutter applications with the toola: desktopRunning on desktopplatform-linuxBuilding on or for Linux specificallyteam-linuxOwned by the Linux platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-linuxTriaged by the Linux platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions