conan
conan copied to clipboard
[bug] Conan incorrectly assumes os_name in runenv_from_cpp_info for transitive dependencies
Environment Details (include every applicable attribute)
- Conan version: 1.52.0
- Python version: 3.8 / 3.10
Steps to reproduce (Include if Applicable)
The problem is that LD_LIBRARY_PATH is not populated for transitive dependencies if recipe doesn't have os setting when using single profile.
- Tool recipe (NOTE: declares settings):
from pathlib import Path
from conan import ConanFile
class ToolConanFile(ConanFile):
name = "tool"
version = "1.0"
settings = "os", "arch"
def package_info(self):
self.cpp_info.bindirs = ["bin"]
self.cpp_info.libdirs = ["lib"]
def package(self):
p = Path(self.package_folder)
(p / "bin").mkdir() # Conan skips non-existing directories
(p / "lib").mkdir()
- Consumer recipe (NOTE: does not have any settings)
from conan import ConanFile
class ConsumerConanFile(ConanFile):
name = "pkgA"
version = "1.0"
tool_requires = "tool/1.0"
generators = "VirtualBuildEnv"
- Create tool package
conan create create ./pkg_tool/conanfile.py -pr default - Try to consume without build profile:
conan install ./pkg_consumer/ -pr default - Generated
conanbuildenv.shcontains onlyPATHvariable set. - Try to consume with build profile:
conan install ./pkg_consumer/ -pr:b default - Generated
conanbuildenv.shcontains bothPATHandLD_LIBRARY_PATH/DYLD_LIBRARY_PATHvariables.
I think this is happening becase Conan strips recipe's settings down to what it declares, and then os_name = self._conanfile.settings.get_safe("os") returns None.
Changing to requires and VirtualRunEnv leads to the same problem.