conan-io / conan-io/docs

[question] build_requires in lockfiles

Open
#1,985 2 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

Hi,

This question is related to this one : https://github.com/conan-io/conan/issues/8268
In a nutshell, i use CONAN_RUN_TESTS to be able to run "conan create" by specifying whether the build_requires should be populated with gtest. It seems to cause problem when working with lockfiles.

For this example i have the same graph as this page : https://docs.conan.io/en/latest/versioning/lockfiles/build_order.html

The issue is that i lose the gtest dependency when deriving the lockfile for app1 :

1 ) Create base lockfile for app1
```
conan lock create conanfile.py
--lockfile=liba_base.lock
--lockfile-out=app1_base.lock
--base
-e CONAN_RUN_TESTS=1

Build requirements
gtest/1.8.1@bincrafters/stable from 'conan-center' - Cache <== OK, present in app1_base.lock
```

2 ) Derive base lockfile
```
conan lock create
--reference=app1/1.0.1@foo/stable
--lockfile=app1_base.lock
--lockfile-out=app1_Release.lock
-s build_type=Release
-e CONAN_RUN_TESTS=1

Build requirements
none <== thus no gtest in app1_Release.lock
(note that app1/1.0.1@foo/stable was created with CONAN_RUN_TESTS=1 so gtest appeared in the build_requires)
```

3 ) This leads to the error :
```
conan install app1/1.0.1@foo/stable
--lockfile=app1_Release.lock
--lockfile-out=locks/app1_Release_updated.lock
--build missing

ERROR: Build-require 'gtest' cannot be found in lockfile
```

4 ) I noticed that by using command without --reference, i still get the gtest dependency in the lockfile
```
conan lock create conanfile.py
--lockfile=app1_base.lock
--lockfile-out=app1_Release.lock
-s build_type=Release
-e CONAN_RUN_TESTS=1

Build requirements
gtest/1.8.1@bincrafters/stable from 'conan-center' - Cache <== OK, present in app1_Release.lock
```

But surprinsingly i still get the same error :

```
conan install app1_src/ --lockfile=app1_Release.lock
--lockfile-out=app1_Release_updated.lock
--build=missing

ERROR: Build-require 'gtest' cannot be found in lockfile
Even if gtest appears in the lockfile.
```

Could you help me clarify this a bit ? I wonder if i am shooting myself in the foot by using this technique with CONAN_RUN_TESTS.
Thanks !

- [X] I've read the [CONTRIBUTING guide](https://github.com/conan-io/conan/blob/develop/.github/CONTRIBUTING.md).

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.