conan
conan copied to clipboard
[bug] tool_requires overrides does not work
Describe the bug
Any OS Any Compiler Any Conan version (I tried 1.63.0 and 2.2.2)
How to reproduce it
- create file requirements.txt file with the following content:
[tool_requires]
gcc/12.2.0
make/4.4.1
cmake/3.29.0
gmp/6.3.0
- Call
conan install requirements.txt --build missing
Output:
======== Computing dependency graph ========
gcc/12.2.0: Not found in local cache, looking in remotes...
gcc/12.2.0: Checking remote: conancenter
gcc/12.2.0: Downloaded recipe revision e2965d35782138942e42af8e7da1faf7
mpc/1.2.0: Not found in local cache, looking in remotes...
mpc/1.2.0: Checking remote: conancenter
mpc/1.2.0: Downloaded recipe revision 3eb7f548f869fd782601e22fcf196a8c
Graph root
requirements.txt: /requirements.txt
Build requirements
gcc/12.2.0#e2965d35782138942e42af8e7da1faf7 - Downloaded (conancenter)
mpc/1.2.0#3eb7f548f869fd782601e22fcf196a8c - Downloaded (conancenter)
ERROR: Version conflict: mpc/1.2.0->gmp/6.3.0, gcc/12.2.0->gmp/6.2.1.
Hi @AndreyMlashkin
Thanks for your report.
This wouldn't be a Conan client bug, but a version conflict. This can be addressed in different ways:
- In the ConanCenter recipes, updating them to align versions, if possible (it is not always possible to do that for every combination of different versions)
- In the client side, you can resolve conflicts in different ways:
- Looking for another set of versions that are compatible, maybe using an older version of
mpc - Using override/force: https://docs.conan.io/2/tutorial/versioning/conflicts.html
- Using
[replace_tool_requires]in your profile: https://docs.conan.io/2/reference/config_files/profiles.html#replace-tool-requires
- Looking for another set of versions that are compatible, maybe using an older version of
I can move this to the conan-center-index repo, to see if there is something there that could be better aligned
Is it possible to add override/force modifier in conanfil.txt?
Is it possible to add override/force modifier in conanfil.txt?
No, it has to be done in conanfile.py
@memsharded, I've put
[replace_tool_requires]
gmp/*: gmp/6.3.0
to the profile, but it does not have any effect, it's even skipped in the conan logs
0.385 ======== Input profiles ========
0.385 Profile host:
0.385 [settings]
0.385 arch=x86_64
0.385 build_type=Debug
0.385 compiler=gcc
0.385 compiler.cppstd=17
0.385 compiler.libcxx=libstdc++11
0.385 compiler.version=11
0.385 os=Linux
0.385 [options]
0.385 *:shared=False
0.385
0.385 Profile build:
0.385 [settings]
0.385 arch=x86_64
0.385 build_type=Debug
0.385 compiler=gcc
0.385 compiler.cppstd=17
0.385 compiler.libcxx=libstdc++11
0.385 compiler.version=11
0.385 os=Linux
0.385 [options]
0.385 *:shared=False
Thanks for the feedback.
As they are transitive requires of the tool_requires it should be:
include(default)
[replace_requires]
gmp/*: gmp/6.3.0
mpfr/*: mpfr/4.2.0
As -pr:b=myprofile (the build profile, not the host one)
Please try that and let me know if this helps (irrespective of the possible updates we might want to do in ConanCenter)
What I am doing wrong here? https://github.com/AndreyMlashkin/minimalistic_conan_docker/tree/use_force_override
To reproduce my problem just call
docker build .
this line does not work:
self.tool_requires("gmp/6.3.0", override=True, force=True)
0.385 Conan version 2.2.3
0.595
0.595 ======== Input profiles ========
0.595 Profile host:
0.595 [settings]
0.595 arch=x86_64
0.595 build_type=Release
0.595 compiler=gcc
0.595 compiler.cppstd=17
0.595 compiler.libcxx=libstdc++11
0.595 compiler.version=11
0.595 os=Linux
0.595 [options]
0.595 *:shared=False
0.595
0.595 Profile build:
0.595 [settings]
0.595 arch=x86_64
0.595 build_type=Release
0.595 compiler=gcc
0.595 compiler.cppstd=17
0.595 compiler.libcxx=libstdc++11
0.595 compiler.version=11
0.595 os=Linux
0.595 [options]
0.595 *:shared=False
0.595
0.607
0.607 ======== Computing dependency graph ========
0.609 ERROR:
0.609 TypeError: ToolRequirements.__call__() got an unexpected keyword argument 'force'
------
Dockerfile:19
--------------------
17 | COPY build_profile /root/.conan2/profiles/build_profile
18 | COPY requirements.py requirements.py
19 | >>> RUN conan -v && conan install requirements.py --build missing -g virtualenv --profile:build=build_profile --profile:host=build_profile
20 |
21 | # remove initial build tools:
--------------------
ERROR: failed to solve: process "/bin/sh -c conan -v && conan install requirements.py --build missing -g virtualenv --profile:build=build_profile --profile:host=build_profile" did not complete successfully: exit code: 1
My only intention is to create a build environment using conan (gcc, cmake, make) I would prefer only have requirements.txt for that.
The gcc recipe in ConanCenter might not be optimal in this regard. The best might be updating the recipe to fix the conflicts, that is the recommended approach anyway.
In your repo, your build profile is wrong. Please note it is not replace_tool_requires but:
[replace_requires]
gmp/*: gmp/6.3.0
mpfr/*: mpfr/4.2.0
Please check my comment above.
In the conanfile it is not possible to define both override=True and force=True. It is also not possible to define tool_requires(..., force=True) this trait is not available for tool_requires at the moment. But with the profile [replace_requires] it shouldn't be necessary.
I have used replace_requires, it worked, thank you!
But now gcc recipe does not compile...
#0 6303.1 checking for isl 0.15 or later... no
#0 6303.2 required isl version is 0.15 or later
#0 6303.2 configure: error: Unable to find a usable isl. See config.log for details.
And it's a wrong place to ask, but maybe you know, why github mirror of gcc contains different archive? (checksum does not match)
https://github.com/gcc-mirror/gcc/archive/refs/tags/releases/gcc-12.2.0.tar.gz does not match https://ftp.gnu.org/gnu/gcc/gcc-12.2.0/gcc-12.2.0.tar.gz
This question arize, because gnu mirror is very slow at least for me