Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] make system_requirements error logger more informative #11706

Closed
1 task done
AndreyMlashkin opened this issue Jul 26, 2022 · 13 comments · Fixed by #11712
Closed
1 task done

[feature] make system_requirements error logger more informative #11706

AndreyMlashkin opened this issue Jul 26, 2022 · 13 comments · Fixed by #11712
Assignees
Milestone

Comments

@AndreyMlashkin
Copy link

AndreyMlashkin commented Jul 26, 2022

currently, error log looks like:

xorg/system: ERROR: while executing system_requirements(): Can't update because tools.system.package_manager:mode is 'check'.Please update packages manually or set 'tools.system.package_manager:mode' to 'install' in the [conf] section of the profile, or in the command line using '-c tools.system.package_manager:mode=install'
ERROR: Error in system requirements

If should contain a list, which packages are missing.

@memsharded
Copy link
Member

Can you please report which tool are you using inside system_requirements()? Because there are 2, the legacy and the new one in from conan.tools.

@AndreyMlashkin
Copy link
Author

I am not sure, what do you exactly mean.
I am installing official xorg/system
https://github.com/conan-io/conan-center-index/blob/master/recipes/xorg/all/conanfile.py

@memsharded
Copy link
Member

Good, that is using the new tooling in from conan.tools.system.package_manager import Apt, Dnf, PacMan, Pkg, Yum, Zypper

@czoido
Copy link
Contributor

czoido commented Jul 26, 2022

Hi @AndreyMlashkin,
Thanks for the feedback. I can open a PR to improve the message. What information do you miss in the message? Maybe it can also be a problem of lack of visibility in the Conan documentation? The new package_manager tools are documented here.

@AndreyMlashkin
Copy link
Author

I would like to see, which packages are missing.
It would be perfect to have the full list of missing dependencies

@czoido
Copy link
Contributor

czoido commented Jul 26, 2022

I would like to see, which packages are missing. It would be perfect to have the full list of missing dependencies

I think the problem is that the recipe in conan-center-index is forcing an update for the packages but that will make that something like apt-get update is executed and that is not allowed if the configuration package_manager:mode is different from install. Let me mark this as look into so I can discuss the implications of this with the team.

@czoido
Copy link
Contributor

czoido commented Jul 26, 2022

@AndreyMlashkin

Did you try to set the conf: tools.system.package_manager:mode=install?

You can do that in the command line like:

conan create ... -c tools.system.package_manager:mode=install

Or in the [conf] section of your Conan profile.

@GavinNL
Copy link

GavinNL commented Jul 26, 2022

My CI is failing with the same error

xorg/system: ERROR: while executing system_requirements(): Can't update because tools.system.package_manager:mode is 'check'.Please update packages manually or set 'tools.system.package_manager:mode' to 'install' in the [conf] section of the profile, or in the command line using '-c tools.system.package_manager:mode=install'

My CI has sudo, but not sure what to do about this. I tried adding the following but it didn't work

conan install .. -c tools.system.package_manager:mode=install

Is there anything else I'm supposed to add?

@czoido
Copy link
Contributor

czoido commented Jul 26, 2022

Hi @GavinNL,
If you also add -c tools.system.package_manager:sudo=True the package manager will be invoked with sudo:

conan install .. -c tools.system.package_manager:mode=install -c tools.system.package_manager:sudo=True

Hope this helps.

@GavinNL
Copy link

GavinNL commented Jul 26, 2022

Ahh okay. looks like that worked. Thanks!

Is there a way to get the list of system packages required by the conanfile? something like:

conan list-required-system-packages ../conanfile.txt

@AndreyMlashkin
Copy link
Author

@AndreyMlashkin

Did you try to set the conf: tools.system.package_manager:mode=install?

You can do that in the command line like:

conan create ... -c tools.system.package_manager:mode=install

Or in the [conf] section of your Conan profile.

I don't need to install the dependencies, I only want to print missing ones. The same as a call
conan install my_dependency/1.1.1@ would do if you don't specify --build missing

@czoido
Copy link
Contributor

czoido commented Jul 27, 2022

Ahh okay. looks like that worked. Thanks!

Is there a way to get the list of system packages required by the conanfile? something like:

conan list-required-system-packages ../conanfile.txt

@GavinNL we don't have a dedicated command for that but you could iterate the dependencies in the conanfile's generate() method and get the list of system libs. Something like:

def generate(self):
    system_libs = []
    for dep in self.dependencies.values():
        if dep.cpp_info.has_components:
            sorted_components = dep.cpp_info.get_sorted_components().items()
            for comp_name, comp_cpp_info in sorted_components:
                system_libs.extend(comp_cpp_info.system_libs)
        else:
            system_libs.extend(dep.cpp_info.system_libs)

    print(system_libs)

In Conan 2.0, there's the possibility to add your own custom commands, so you could make your own command for that. You can read about that in the Conan 2.0 documentation.

@czoido
Copy link
Contributor

czoido commented Jul 27, 2022

@AndreyMlashkin
We have merged #11712 and will be released in 1.51, from that version you will see what packages are missing being in mode=check, so this should solve your issue.

@czoido czoido closed this as completed Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants