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] docker runner doesn't work when conanfile is inside subfolder #17746

Open
aagor opened this issue Feb 10, 2025 · 4 comments · May be fixed by #17542
Open

[bug] docker runner doesn't work when conanfile is inside subfolder #17746

aagor opened this issue Feb 10, 2025 · 4 comments · May be fixed by #17542
Assignees

Comments

@aagor
Copy link

aagor commented Feb 10, 2025

Describe the bug

Environment details:

  • OS: Linux
  • Conan version: 2.12.1
  • Conan profile: nothing special, use docker runner as described here

When using the docker runner, only the current directory get's mapped into the container.
This is not sufficient when the Conanfile is in a subfolder like in this example: Declaring the layout when the Conanfile is inside a subfolder.
Conan then can't access the root folder, as it's not mapped into the container and therefore fails to access files, leading to a build fail.

How to reproduce it

$ git clone https://github.com/conan-io/examples2.git
$ cd examples2/examples/conanfile/layout/conanfile_in_subfolder/conan
$ conan create .
> Build fails here
$ docker inspect conan-runner-docker |jq .[].HostConfig.Binds

jq output:

[
  "/home/<username>/examples2/examples/conanfile/layout/conanfile_in_subfolder/conan:/root/conanrunner/conan:rw"
]
@perseoGI
Copy link
Contributor

Hi @aagor thank you for your report!
That is definitely a great catch!

We are improving the conan runners, I'll include a workaround for this issue in #17542
Stay tuned for incoming updates.
I'll inform here when this problem is addressed

Happy coding 🐸

@perseoGI
Copy link
Contributor

Greetings @aagor,

I've been discussing with the team and we are considering giving support to this specific case.
The docker runner only mounts the directory where the conanfile.py file resides.
Mounting parent directories automatically is currently not supported.

But here is a quick workaround to address this issue:

  1. Edit your docker profile adding a configfile key:
[runner]
type=docker
...
configfile=<absolute_path>/configfile.yml
  1. Create a configfile.yml following the schema specified here: https://containers.dev/implementors/json_reference/
run:
    mounts:
        <absolute_path>/examples2/examples/conanfile/layout/conanfile_in_subfolder/:
            bind: /root/conanrunner/   # This is the mount folder inside the docker runner -> kind of internal to conan...
            mode: rw
  1. Execute conan create again and this time should work.

I hope it helps!

perseoGI added a commit to perseoGI/conan that referenced this issue Feb 11, 2025
@aagor
Copy link
Author

aagor commented Feb 13, 2025

Hi,
I can confirm that the workaround works.
Thanks.

@perseoGI
Copy link
Contributor

Hi there!
I'm glad to hear it helps!

I'm introducing some changes and tests on the incoming runners to support this kind of project where conanfile is inside a subfolder.

perseoGI added a commit to perseoGI/conan that referenced this issue Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants