conan-io / conan-io/docs

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

Open
#4,036 4 comments 0 reactions 1 assignee Claimed by @memsharded View on GitHub
Dominant language
C++
Stars
125
Forks
382
Avg merge
22h 39m
Merged PRs (30d)
21

Description

### 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
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.