Skip to content

Commit 06f5032

Browse files
authored
Replace requires entry (#4389)
1 parent 427ac61 commit 06f5032

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

reference/conanfile/methods/build_requirements.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ should the *requires* and *tool_requires* have different names. For instance:
110110
If we want to also keep the same ``user`` and ``channel`` fields, we'd need to
111111
specify it in the tool requirements reference as well, i.e., ``self.tool_requires("protobuf/<host_version>@mycompany/fork")``.
112112

113+
The ``<host_version>`` feature also works when the requirement is replaced using the :ref:`[replace_requires]<reference_config_files_profiles_replace_requires>`
114+
section in your profile, so that the replaced version would be used in both contexts at once.
115+
116+
.. note::
117+
118+
If your ``[replace_requires]`` is replacing not only the version, but also the ``user``/``channel`` fields,
119+
(so for example replacing ``protobuf/*: protobuf/3.18.1@mycompany/fork``)
120+
and you would like to also use the same ``user`` and ``channel`` fields in the build context,
121+
you should use the :ref:`[replace_tool_requires]<reference_config_files_profiles_replace_tool_requires>`
122+
to replace it in the build context as well, otherwise the ``<host_version>`` will look for
123+
``protobuf/3.18.1`` without the ``user`` and ``channel`` fields in the build context as explained in the previous warning,
124+
which could lead to unexpected results.
125+
113126

114127
.. _reference_conanfile_methods_build_requirements_test_requires:
115128

0 commit comments

Comments
 (0)