You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: reference/tools/env/virtualbuildenv.rst
+45-4Lines changed: 45 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -107,11 +107,52 @@ will create the following files:
107
107
Please open a Github ticket to report any feedback about this feature.
108
108
109
109
110
-
.. note::
111
110
112
-
Disabling the automatic generation of these files for consumers can be achieved by passing ``--envs-generation=false`` to the ``conan install`` command.
113
-
**This feature is experimental and subject to change**, and disabling this file can lead to unexpected build errors,
114
-
if for example ``tool_requires`` are used. Ensure they are not needed if the generation is disabled.
111
+
.. _reference_tools_env_virtualbuildenv_disable:
112
+
113
+
Disabling VirtualBuildEnv
114
+
-------------------------
115
+
116
+
It is possible to disable the generation of the ``VirtualBuildEnv`` and ``VirtualRunEnv`` files with
117
+
different mechanisms:
118
+
119
+
- By passing ``--envs-generation=false`` to the ``conan install`` command, it will disable the generation
120
+
of environment files (both ``VirtualBuildEnv`` and ``VirtualRunEnv``) for the current consumer only
121
+
(dependencies that need to be built from source will generate their own environment files as needed).
122
+
**This feature is experimental and subject to change**.
123
+
- Recipes can instantiate a ``VirtualBuildEnv(self)`` in their ``generate()`` method, without calling
124
+
their ``generate()`` method. That will inhibit the creation of environment files for that specific
125
+
recipe:
126
+
127
+
.. code-block:: python
128
+
129
+
defgenerate(self):
130
+
VirtualBuildEnv(self)
131
+
# do not call its generate() method
132
+
# discouraged, in most cases, it is desired
133
+
# to call generate()
134
+
VirtualRunEnv(self)
135
+
# Same for VirtualRunEnv
136
+
137
+
- Recipes can directly define their ``virtualbuildenv = False`` attribute to inhibit the automatic
138
+
default creation of ``VirtualBuildEnv`` files for this recipe:
139
+
140
+
.. code-block:: python
141
+
142
+
classPkg(ConanFile):
143
+
virtualbuildenv =False
144
+
# Also for VirtualRunEnv
145
+
virtualrunenv =False
146
+
147
+
148
+
.. warning::
149
+
150
+
In general, disabling the generation of environment files is **discouraged**. Environment files are the
151
+
mechanism use for things like ``[tool_requires]`` defined in the profiles to be able to inject those
152
+
tools dynamically in dependencies, even if those dependencies didn't directly declare such
153
+
``tool_requires``. Without proper ``VirtualBuildEnv`` files in the recipe, the ``tool_requires`` will
Copy file name to clipboardExpand all lines: reference/tools/env/virtualrunenv.rst
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,8 +80,8 @@ current active configuration, like ``deactivate_conanrunenv-release-x86_64.bat``
80
80
81
81
.. note::
82
82
83
-
Disabling the automatic generation of these files for consumers can be achieved by passing ``--env-generation=false`` to the ``conan install`` command.
84
-
**This feature is experimental and subject to change**, and disabling this file can lead to unexpected runtime errors.
83
+
For disabling the automatic generation of environment files, check :ref:`reference_tools_env_virtualbuildenv_disable`
0 commit comments