conan-io / conan-io/docs

[missing doc] Undocumented side-effect and parameter `auto_generate`

Open
#3,676 1 comment 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

By default, conan2 uses `VirtualRunEnv` and `VirtualBuildEnv` generators (this is briefly mentioned but is missing from the `VirtualRunEnv` doc).

However, if a generator (or anything from the top conanfile) instantiates `VirtualRunEnv` (or `VirtualBuildEnv`) for its own use, this will have a side effect, prevent the default behavior and `VirtualRunEnv.generate()` will never be called (so `conanrun.sh` won't be present).

A solution is to use the undocumented parameter `auto_generate=True` or to explicitly call `self.virtual_run_env.generate()` everytime `VirtualRunEnv()` is instantiated.

It would be nice to document the parameter, default behavior and side effect (if intended).

Relevant code:
https://github.com/conan-io/conan/blob/ad0b39c228ecb6b5539fb5995c7a3e98f85c9bf9/conan/tools/env/virtualrunenv.py#L39-L40

The behavior was introduced in https://github.com/conan-io/conan/pull/9543

### How to reproduce it

```python
from conan.tools.env import VirtualBuildEnv, VirtualRunEnv

class MyGenerator:
def __init__(self, conanfile):
self._conanfile = conanfile
# This will prevent `conanrun.sh` to be generated
self.virtual_run_env = VirtualRunEnv(conanfile, auto_generate=False)
self.virtual_build_env = VirtualBuildEnv(conanfile, auto_generate=False)

def generate(self):
pass

```

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.