Search code examples
ubuntucmakeconan

Conan fails from inside container with "sudo: not found" error


I am trying to build a project as part of a CI pipeline from an Ubuntu image.

I have pasted the last few lines logged below:

Not updating system_requirements. CONAN_SYSREQUIRES_MODE=verify
Running: sudo -A apt-get install -y --no-install-recommends libfontenc-dev libice-dev libsm-dev libx11-xcb-dev libxaw7-dev libxcb-dri3-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-util-dev libxcb-xfixes0-dev libxcb-xinerama0-dev libxcb-xkb-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 xkb-data
/bin/sh: 1: sudo: not found
xorg/system: ERROR: while executing system_requirements(): Command 'sudo -A apt-get install -y --no-install-recommends libfontenc-dev libice-dev libsm-dev libx11-xcb-dev libxaw7-dev libxcb-dri3-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-util-dev libxcb-xfixes0-dev libxcb-xinerama0-dev libxcb-xkb-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 xkb-data' failed
ERROR: Error in system requirements
CMake Error at build/conan.cmake:631 (message):
  Conan install failed='1'
Call Stack (most recent call first):
  cmake/Conan.cmake:47 (conan_cmake_install)
  CMakeLists.txt:42 (run_conan)
-- Configuring incomplete, errors occurred!

Is this because thngs are already running as the root user? If so, is there a way to get conan to run without calling sudo?

For those who want to reproduce the error:

  1. Start a ubuntu:20.10 docker image
  2. Run
$ apt update && apt install -y python3-pip pkg-config libudev-dev libgl-dev
  1. Install conan: pip install conan
  2. Create a conanfile.txt with the following contents
[requires]
sfml/2.5.1
  1. Run conan install path/to/conanfile.txt
  2. Observe the error pasted above

Solution

  • When you specify libA as a dependency in your conanfile, it will also install all dependencies required by libA. However, some packages in conan (not many) also have "system requirements". A system requirement is just another dependency of the package, but one that has not yet been package as a conan package and is instead installed through your system package manager. The package you are trying to install has at least one system requirement.

    When there is a system requirement, conan will need administration privileges, since it will call you system package manager to install that requirement. In the case of Linux, that administration privileges means using sudo. However, the image you are using in CI does not have sudo.

    If you can, just use a different image that contains sudo and it should work.

    You can also take a look at the recipe of the conan package that you are trying to use. Packages can provide options and it is possible that the package you are trying to use has some option to, for instance, not enable some feature and thus not depend on some library.

    For more information than this you would need to inform which package you are trying to use.