Skip to content

[bug] order of configuration options not preserved in all cases #4036

@wuziq

Description

@wuziq

Describe the bug

Environment details:

$ conan --version
Conan version 2.13.0
$ lsb_release -d
Description:    Ubuntu 22.04.5 LTS

Description:

The order of [conf] options isn't always preserved. Example:

$ cat .conan2/profiles/mold-with-test-options
...
[conf]
&:tools.cmake.cmaketoolchain:user_toolchain+={{profile_dir}}/toolchains/mold.cmake
tools.build:skip_test=true
&:tools.build:skip_test=false

$ conan profile show -pr:a mold-with-test-options
Host profile:
...
[conf]
&:tools.build:skip_test=false
&:tools.cmake.cmaketoolchain:user_toolchain=['/home/me/.conan2/profiles/toolchains/mold.cmake']
tools.build:skip_test=true

As a result, the root project's tests aren't built, I think because tools.build:skip_test=true comes after &:tools.build:skip_test=false and overrides it.

(Note that the "resolved" order given by conan profile show indeed applies to the actual build and is not merely just for display.)

However, this works:

$ cat .conan2/profiles/mold-with-test-options
...
[conf]
tools.build:skip_test=true
&:tools.build:skip_test=false
&:tools.cmake.cmaketoolchain:user_toolchain+={{profile_dir}}/toolchains/mold.cmake

$ conan profile show -pr:a mold-with-test-options
Host profile:
...
[conf]
tools.build:skip_test=true
&:tools.build:skip_test=false
&:tools.cmake.cmaketoolchain:user_toolchain=['/home/me/.conan2/profiles/toolchains/mold.cmake']

And this works, too:

$ cat .conan2/profiles/mold-with-test-options
...
[conf]
tools.build:skip_test=true
&:tools.cmake.cmaketoolchain:user_toolchain+={{profile_dir}}/toolchains/mold.cmake
&:tools.build:skip_test=false

$ conan profile show -pr:a mold-with-test-options
Host profile:
...
[conf]
tools.build:skip_test=true
&:tools.build:skip_test=false
&:tools.cmake.cmaketoolchain:user_toolchain=['/home/me/.conan2/profiles/toolchains/mold.cmake']

The same issue seems to exist when supplying the configuration options on the command line. Example:

$ conan profile show -pr:a no-mold -c "&:tools.cmake.cmaketoolchain:user_toolchain=['/home/me/.conan2/profiles/toolchains/mold.cmake']" -c tools.build:skip_test=true -c "&:tools.build:skip_test=false"
Host profile:
...
[conf]
&:tools.build:skip_test=false
&:tools.cmake.cmaketoolchain:user_toolchain=['/home/me/repos/.conan2/profiles/toolchains/mold.cmake']
tools.build:skip_test=true

How to reproduce it

The simplest way is to just run conan profile show using a profile that has no [conf] section, and with the 3 different options provided on the command line, much like the last example I provided. It doesn't seem to matter whether the toolchain file exists:

$ conan profile show -pr:a default -c tools.build:skip_test=true -c "&:tools.cmake.cmaketoolchain:user_toolchain=['foo.cmake']" -c "&:tools.build:skip_test=false"
Host profile:
...
[conf]
tools.build:skip_test=true
&:tools.build:skip_test=false
&:tools.cmake.cmaketoolchain:user_toolchain=['foo.cmake']

$ conan profile show -pr:a default -c "&:tools.cmake.cmaketoolchain:user_toolchain=['foo.cmake']" -c tools.build:skip_test=true -c "&:tools.build:skip_test=false"
Host profile:
...
[conf]
&:tools.build:skip_test=false
&:tools.cmake.cmaketoolchain:user_toolchain=['foo.cmake']
tools.build:skip_test=true

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions