conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.14k stars 970 forks source link

[bug] Wrong paths to profiles in docker runner #16812

Open czertyaka opened 1 month ago

czertyaka commented 1 month ago

Describe the bug

Environment details:

Description:

I was following tutorial "Creating a Conan package using a Docker runner" and failed to create zlib package in docker runner. The step which seems to cause the issue is executing conan create command on host which subsequently runs conan create in docker container. It failed with following error message:

ERROR: Profile not found: /tmp/tmp.Xqv39esrqB-docker-runner/docker_example_build

Command itself, which was generated by conan, was:

Running in container: "conan create /root/conanrunner/all --version 1.3.1 -pr:h /tmp/tmp.Xqv39esrqB-docker-runner/docker_example_host -pr:b /tmp/tmp.Xqv39esrqB-docker-runner/docker_example_build -f json > create.json"

I overall get the error message. Indeed, there was no /tmp/tmp.Xqv39esrqB-docker-runner/docker_example_build file in the container, nor did /tmp/tmp.Xqv39esrqB-docker-runner/ directory exist. These was a valid absolute path on host, but not in container.

According to tutorial, conan was supposed to replace this path with comething like /root/conanrunner/all/.conanrunner/profiles/. This, however, did not happen.

I tried to investigate it, and logged in running container as root. This lead me to a further surprise: I did not manage to find profiles docker_example_build and docker_example_host at all!

docker$ pwd
/root/conanrunner/all/.conanrunner/profiles
docker$ ls -al
total 8
drwxr-xr-x 2 1000 1000  80 Feb 11 15:23 .
drwxr-xr-x 3 1000 1000 140 Aug 11 17:56 ..
-rw-r--r-- 1 1000 1000 134 Jul 29 19:04 default
-rw-r--r-- 1 1000 1000 134 Feb 11 15:23 std98
docker$ find / -name docker_example_build

My further attempts to run conan config install on directory with profiles and change [runner] sections values were to no avail. My guess that it has something to do with #16364.

How to reproduce it

Essentially, reproducing the issue for me was following this tutorial. I'm providing more detailed info on how exactly I was doing it here.

  1. I will for convenience use in following steps the same directory I was working in. So, the first step would be creating it:

    $ mkdir /tmp/tmp.Xqv39esrqB-docker-runner
    $ cd /tmp/tmp.Xqv39esrqB-docker-runner
  2. Create Python virtual environment and activate it:

    $ python -m venv .venv
    $ source .venv/bin/activate
  3. Install conan and conan[runners] packages:

    $ pip install conan==2.6.0 conan[runners]
  4. Create two profiles and Dockerfile as described in tutorial:

    $ cat Dockerfile
    FROM ubuntu:22.04
    RUN apt-get update \
        && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
            build-essential \
            cmake \
            python3 \
            python3-pip \
            python3-venv \
        && rm -rf /var/lib/apt/lists/*
    RUN pip install conan==2.6.0
    $ cat docker_example_host
    [settings]
    arch=x86_64
    build_type=Release
    compiler=gcc
    compiler.cppstd=gnu17
    compiler.libcxx=libstdc++11
    compiler.version=11
    os=Linux
    [runner]
    type=docker
    dockerfile=/tmp/tmp.Xqv39esrqB-docker-runner/
    cache=copy
    remove=false
    $ cat docker_example_build
    [settings]
    arch=x86_64
    build_type=Release
    compiler=gcc
    compiler.cppstd=gnu17
    compiler.libcxx=libstdc++11
    compiler.version=12
    os=Linux
  5. Clone zlib recipe:

    $ git clone https://github.com/conan-io/conan-center-index.git --depth=1
  6. Run conan:

    $ conan create ./conan-center-index/recipes/zlib/all --version 1.3.1 -pr:h $(pwd)/docker_example_host -pr:b $(pwd)/docker_example_build
    ...
    Running in container: "conan create /root/conanrunner/all --version 1.3.1 -pr:h /tmp/tmp.Xqv39esrqB-docker-runner/docker_example_host -pr:b /tmp/tmp.Xqv39esrqB-docker-runner/docker_example_build -f json > create.json"
    
    ERROR: Profile not found: /tmp/tmp.Xqv39esrqB-docker-runner/docker_example_build
    
    ERROR: Stopping container
    
    ERROR: "conan create /root/conanrunner/all --version 1.3.1 -pr:h /tmp/tmp.Xqv39esrqB-docker-runner/docker_example_host -pr:b /tmp/tmp.Xqv39esrqB-docker-runner/docker_example_build -f json > create.json" inside docker fail

The output of the last command is a little to large for it to be included and can be found in the attachments: conan_create.log

YassineLambarki commented 1 month ago

+1 [env]

ubuntu_version="22.04.4 LTS (Jammy Jellyfish)"
conan_version="Conan version 2.6.0"
docker_version="Docker version 26.1.3, build b72abbb"