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

[bug] SystemPackageTool installs packages when it should not #10592

Closed
ericLemanissier opened this issue Feb 16, 2022 · 8 comments · Fixed by #10596
Closed

[bug] SystemPackageTool installs packages when it should not #10592

ericLemanissier opened this issue Feb 16, 2022 · 8 comments · Fixed by #10596
Assignees
Milestone

Comments

@ericLemanissier
Copy link
Contributor

By default, SystemPackageTool should not install any system packages, but just check if they are installed.
The very surprising part, is that it displays Not updating system_requirements. CONAN_SYSREQUIRES_MODE=verify just before installing system packages.

Environment Details

  • Operating System+version: Linux
  • Conan version: 1.44.1
  • Python version: 3.8.10

Steps to reproduce

sudo apt remove libx11-dev && rm -r ~/.conan/data/xorg && CONAN_SYSREQUIRES_MODE=verify conan install xorg/system@

also

sudo apt remove libx11-dev && rm -r ~/.conan/data/xorg && conan install xorg/system@

Logs

Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=9
os=Linux
os_build=Linux
cmake:build_type=Release
ninja:build_type=Release
[options]
[build_requires]
[env]

xorg/system: Not found in local cache, looking in remotes...
xorg/system: Trying with 'conan-center'...
WARN: Hook 'yamllinter.py' not found in /home/eric/.conan/hooks folder. Please remove hook from conan.conf or include it inside the hooks folder.
WARN: Hook 'recipe-linter.py' not found in /home/eric/.conan/hooks folder. Please remove hook from conan.conf or include it inside the hooks folder.
xorg/system: Downloaded recipe revision f124447df2885b3632d1b94ba20b6294
Installing package: xorg/system
Requirements
    xorg/system from 'conan-center' - Downloaded
Packages
    xorg/system:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Download

Installing (downloading, building) binaries...
xorg/system: Retrieving package 5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 from remote 'conan-center'
Decompressing conan_package.tgz completed [0.00k]
xorg/system: Package installed 5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
xorg/system: Downloaded package revision d135200c4b2ca547d117997d6b2917ce
dpkg-query: no packages found matching libx11-dev
dpkg-query: no packages found matching libx11-xcb-dev
Package already installed: libfontenc-dev
dpkg-query: no packages found matching libx11-dev
dpkg-query: no packages found matching libx11-xcb-dev
dpkg-query: no packages found matching libxaw7-dev
dpkg-query: no packages found matching libxcomposite-dev
dpkg-query: no packages found matching libxcursor-dev
dpkg-query: no packages found matching libxdamage-dev
dpkg-query: no packages found matching libxext-dev
dpkg-query: no packages found matching libxfixes-dev
dpkg-query: no packages found matching libxft-dev
dpkg-query: no packages found matching libxi-dev
dpkg-query: no packages found matching libxinerama-dev
dpkg-query: no packages found matching libxkbfile-dev
dpkg-query: no packages found matching libxmu-dev
dpkg-query: no packages found matching libxmuu-dev
dpkg-query: no packages found matching libxpm-dev
dpkg-query: no packages found matching libxrandr-dev
dpkg-query: no packages found matching libxrender-dev
dpkg-query: no packages found matching libxres-dev
dpkg-query: no packages found matching libxss-dev
dpkg-query: no packages found matching libxt-dev
dpkg-query: no packages found matching libxtst-dev
dpkg-query: no packages found matching libxv-dev
dpkg-query: no packages found matching libxvmc-dev
dpkg-query: no packages found matching libxxf86vm-dev
Not updating system_requirements. CONAN_SYSREQUIRES_MODE=verify
Running: sudo apt-get install -y --no-install-recommends libx11-dev libx11-xcb-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libegl-mesa0 libegl1 libgbm1 libgl1 libgl1-mesa-dri libglx-mesa0 libglx0 libvdpau1 libwayland-server0
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libxmu-headers
Suggested packages:
  libx11-doc libxaw-doc libxext-doc libxt-doc
The following NEW packages will be installed:
  libx11-dev libx11-xcb-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmu-headers libxmuu-dev
  libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev
0 upgraded, 25 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/2089 kB of archives.
After this operation, 8525 kB of additional disk space will be used.
Selecting previously unselected package libx11-dev:amd64.
(Reading database ... 60821 files and directories currently installed.)
Preparing to unpack .../00-libx11-dev_2%3a1.6.9-2ubuntu1.2_amd64.deb ...
Unpacking libx11-dev:amd64 (2:1.6.9-2ubuntu1.2) ...
Selecting previously unselected package libx11-xcb-dev:amd64.
Preparing to unpack .../01-libx11-xcb-dev_2%3a1.6.9-2ubuntu1.2_amd64.deb ...
Unpacking libx11-xcb-dev:amd64 (2:1.6.9-2ubuntu1.2) ...
Selecting previously unselected package libxext-dev:amd64.
Preparing to unpack .../02-libxext-dev_2%3a1.3.4-0ubuntu1_amd64.deb ...
Unpacking libxext-dev:amd64 (2:1.3.4-0ubuntu1) ...
Selecting previously unselected package libxt-dev:amd64.
Preparing to unpack .../03-libxt-dev_1%3a1.1.5-1_amd64.deb ...
Unpacking libxt-dev:amd64 (1:1.1.5-1) ...
Selecting previously unselected package libxmu-headers.
Preparing to unpack .../04-libxmu-headers_2%3a1.1.3-0ubuntu1_all.deb ...
Unpacking libxmu-headers (2:1.1.3-0ubuntu1) ...
Selecting previously unselected package libxmu-dev:amd64.
Preparing to unpack .../05-libxmu-dev_2%3a1.1.3-0ubuntu1_amd64.deb ...
Unpacking libxmu-dev:amd64 (2:1.1.3-0ubuntu1) ...
Selecting previously unselected package libxpm-dev:amd64.
Preparing to unpack .../06-libxpm-dev_1%3a3.5.12-1_amd64.deb ...
Unpacking libxpm-dev:amd64 (1:3.5.12-1) ...
Selecting previously unselected package libxaw7-dev:amd64.
Preparing to unpack .../07-libxaw7-dev_2%3a1.0.13-1_amd64.deb ...
Unpacking libxaw7-dev:amd64 (2:1.0.13-1) ...
Selecting previously unselected package libxfixes-dev:amd64.
Preparing to unpack .../08-libxfixes-dev_1%3a5.0.3-2_amd64.deb ...
Unpacking libxfixes-dev:amd64 (1:5.0.3-2) ...
Selecting previously unselected package libxcomposite-dev:amd64.
Preparing to unpack .../09-libxcomposite-dev_1%3a0.4.5-1_amd64.deb ...
Unpacking libxcomposite-dev:amd64 (1:0.4.5-1) ...
Selecting previously unselected package libxrender-dev:amd64.
Preparing to unpack .../10-libxrender-dev_1%3a0.9.10-1_amd64.deb ...
Unpacking libxrender-dev:amd64 (1:0.9.10-1) ...
Selecting previously unselected package libxcursor-dev:amd64.
Preparing to unpack .../11-libxcursor-dev_1%3a1.2.0-2_amd64.deb ...
Unpacking libxcursor-dev:amd64 (1:1.2.0-2) ...
Selecting previously unselected package libxdamage-dev:amd64.
Preparing to unpack .../12-libxdamage-dev_1%3a1.1.5-2_amd64.deb ...
Unpacking libxdamage-dev:amd64 (1:1.1.5-2) ...
Selecting previously unselected package libxft-dev:amd64.
Preparing to unpack .../13-libxft-dev_2.3.3-0ubuntu1_amd64.deb ...
Unpacking libxft-dev:amd64 (2.3.3-0ubuntu1) ...
Selecting previously unselected package libxi-dev:amd64.
Preparing to unpack .../14-libxi-dev_2%3a1.7.10-0ubuntu1_amd64.deb ...
Unpacking libxi-dev:amd64 (2:1.7.10-0ubuntu1) ...
Selecting previously unselected package libxinerama-dev:amd64.
Preparing to unpack .../15-libxinerama-dev_2%3a1.1.4-2_amd64.deb ...
Unpacking libxinerama-dev:amd64 (2:1.1.4-2) ...
Selecting previously unselected package libxkbfile-dev:amd64.
Preparing to unpack .../16-libxkbfile-dev_1%3a1.1.0-1_amd64.deb ...
Unpacking libxkbfile-dev:amd64 (1:1.1.0-1) ...
Selecting previously unselected package libxmuu-dev:amd64.
Preparing to unpack .../17-libxmuu-dev_2%3a1.1.3-0ubuntu1_amd64.deb ...
Unpacking libxmuu-dev:amd64 (2:1.1.3-0ubuntu1) ...
Selecting previously unselected package libxrandr-dev:amd64.
Preparing to unpack .../18-libxrandr-dev_2%3a1.5.2-0ubuntu1_amd64.deb ...
Unpacking libxrandr-dev:amd64 (2:1.5.2-0ubuntu1) ...
Selecting previously unselected package libxres-dev:amd64.
Preparing to unpack .../19-libxres-dev_2%3a1.2.0-4_amd64.deb ...
Unpacking libxres-dev:amd64 (2:1.2.0-4) ...
Selecting previously unselected package libxss-dev:amd64.
Preparing to unpack .../20-libxss-dev_1%3a1.2.3-1_amd64.deb ...
Unpacking libxss-dev:amd64 (1:1.2.3-1) ...
Selecting previously unselected package libxtst-dev:amd64.
Preparing to unpack .../21-libxtst-dev_2%3a1.2.3-1_amd64.deb ...
Unpacking libxtst-dev:amd64 (2:1.2.3-1) ...
Selecting previously unselected package libxv-dev:amd64.
Preparing to unpack .../22-libxv-dev_2%3a1.0.11-1_amd64.deb ...
Unpacking libxv-dev:amd64 (2:1.0.11-1) ...
Selecting previously unselected package libxvmc-dev:amd64.
Preparing to unpack .../23-libxvmc-dev_2%3a1.0.12-2_amd64.deb ...
Unpacking libxvmc-dev:amd64 (2:1.0.12-2) ...
Selecting previously unselected package libxxf86vm-dev:amd64.
Preparing to unpack .../24-libxxf86vm-dev_1%3a1.1.4-1build1_amd64.deb ...
Unpacking libxxf86vm-dev:amd64 (1:1.1.4-1build1) ...
Setting up libx11-dev:amd64 (2:1.6.9-2ubuntu1.2) ...
Setting up libxfixes-dev:amd64 (1:5.0.3-2) ...
Setting up libxt-dev:amd64 (1:1.1.5-1) ...
Setting up libxpm-dev:amd64 (1:3.5.12-1) ...
Setting up libxext-dev:amd64 (2:1.3.4-0ubuntu1) ...
Setting up libxres-dev:amd64 (2:1.2.0-4) ...
Setting up libxi-dev:amd64 (2:1.7.10-0ubuntu1) ...
Setting up libxrender-dev:amd64 (1:0.9.10-1) ...
Setting up libxft-dev:amd64 (2.3.3-0ubuntu1) ...
Setting up libxtst-dev:amd64 (2:1.2.3-1) ...
Setting up libxkbfile-dev:amd64 (1:1.1.0-1) ...
Setting up libxdamage-dev:amd64 (1:1.1.5-2) ...
Setting up libx11-xcb-dev:amd64 (2:1.6.9-2ubuntu1.2) ...
Setting up libxmu-headers (2:1.1.3-0ubuntu1) ...
Setting up libxcomposite-dev:amd64 (1:0.4.5-1) ...
Setting up libxcursor-dev:amd64 (1:1.2.0-2) ...
Setting up libxxf86vm-dev:amd64 (1:1.1.4-1build1) ...
Setting up libxmu-dev:amd64 (2:1.1.3-0ubuntu1) ...
Setting up libxss-dev:amd64 (1:1.2.3-1) ...
Setting up libxv-dev:amd64 (2:1.0.11-1) ...
Setting up libxrandr-dev:amd64 (2:1.5.2-0ubuntu1) ...
Setting up libxinerama-dev:amd64 (2:1.1.4-2) ...
Setting up libxaw7-dev:amd64 (2:1.0.13-1) ...
Setting up libxmuu-dev:amd64 (2:1.1.3-0ubuntu1) ...
Setting up libxvmc-dev:amd64 (2:1.0.12-2) ...
Processing triggers for man-db (2.9.1-1) ...
Aggregating env generators
@memsharded
Copy link
Member

There is a new tool for system packages in https://docs.conan.io/en/latest/reference/conanfile/tools/system/package_manager.html. Its default should be not install only check. It would be great to double check this is correct @czoido

As SystemPackageTool is removed from 2.0 and migrating to the new tools will be necessary, changing the current SystemPackageTool might be risky, unless it is very clear the fix, maybe not touch it if it can be breaking

@czoido
Copy link
Contributor

czoido commented Feb 16, 2022

There is a new tool for system packages in https://docs.conan.io/en/latest/reference/conanfile/tools/system/package_manager.html. Its default should be not install only check. It would be great to double check this is correct @czoido

As SystemPackageTool is removed from 2.0 and migrating to the new tools will be necessary, changing the current SystemPackageTool might be risky, unless it is very clear the fix, maybe not touch it if it can be breaking

In the new implementation it is covered by this test:

def test_tools_install_mode_check(tool_class):

Anyway I double checked with a functional test and it's working as expected.

@derived-coder
Copy link

derived-coder commented Feb 16, 2022

How can I define in the recipe, that the requirement should be installed?
So I am talking about this mode here: tools.system.package_manager:mode
Can I modify it via script in the recipe?

I also suggest another mode: "ask"
So the user will be asked whether he wants to install it or not. I think this is more user friendly.

@ericLemanissier
Copy link
Contributor Author

@derived-coder I suggest you create another issue, because this issue is not related to conan.tools.system.package_manager

memsharded pushed a commit that referenced this issue Feb 16, 2022
In this case, never install any package

fixes #10592
@memsharded memsharded added this to the 1.46 milestone Feb 16, 2022
@derived-coder
Copy link

@ericLemanissier #10605

@EstebanDugueperoux2
Copy link

Hello,

I have a newbie question about tools.system.package_manager:mode configuration as described in https://docs.conan.io/en/latest/reference/conanfile/tools/system/package_manager.html#conan-tools-system-package-manager

I have a recipe with following snippet:

    def system_requirements(self):
        tools.system.package_manager:mode = "install"
        if os_info.linux_distro == "ubuntu":
            Apt(self).install(["gcovr"], update=True, check=True)
        elif os_info.linux_distro == "fedora" or os_info.linux_distro == "centos":
            Yum(self).install(["gcovr"], update=True, check=True)

But when executing conan create . I get ERROR: while executing system_requirements(): name 'tools' is not defined message.

Could you help me on the correct way to change tools.system.package_manager:mode configuration property?

Regards.

@czoido
Copy link
Contributor

czoido commented Jul 19, 2022

Hi @EstebanDugueperoux2,

Please, read the docs about how to use the configuration properties. You can't use it directly in the recipes as you are doing, you can do it several ways:

  1. Defining it in the global.conf file located in the Conan user home directory
  2. Define it in your profile in the [conf] section:
[settings]
...

[conf]
tools.system.package_manager:mode=install
  1. Pass the conf as an argument in the conan create:
conan create . -c tools.system.package_manager:mode=install
  1. You can also define it in your recipes

Hope this helps!

@czoido
Copy link
Contributor

czoido commented Jul 19, 2022

@EstebanDugueperoux2

Also, please check that you don't need to check the distro for the new system.package_manager tools. Just do the calls and only the active package manager that will be the one that corresponds with the distro will be called, just do:

Apt(self).install(["gcovr"], update=True, check=True)
Yum(self).install(["gcovr"], update=True, check=True)

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

Successfully merging a pull request may close this issue.

5 participants