conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.25k stars 980 forks source link

[question] Env var values from package_info() taken over system env vars #16535

Closed MTomBosch closed 4 months ago

MTomBosch commented 4 months ago

What is your question?

Hi, we are using Conan 1.x.

We have a package that provides an env var via the package_info() method, let's say VAR=PKG_VALUE.

Now we have seen that in case the system environment has set VAR=SYS_VALUE but the above mentioned package is in the dependency tree, then the package defined env var value is used in the cmake based build in the Conan recipe. The system defined env var value is simply ignored.

I guess this is on purpose, correct?

Is there any way to overrule this behaviour for certain env vars without touching the recipe of the package that defines the env var?

Thank you

Have you read the CONTRIBUTING guide?

jcar87 commented 4 months ago

Hi @MTomBosch - indeed this is the intended behaviour, that is, that if a package_info() defines an environment variable, it affects consumers - at this point the "system" variable would not be visible.

I'm not sure this can be altered - if you are using the newer integrations, you can probably "unset" the variable at the consumer side, but I'm fairly certain that would level unset (no value from either the package or the system). It might be possible to give it another value (redefine it) - if the Conan process is exposed to that system environment variable, I suppose it can re-define the variable - but this would be fragile .

MTomBosch commented 4 months ago

Thanks for the quick answer and confirmation of my guess.