conan icon indicating copy to clipboard operation
conan copied to clipboard

[bug] Conan incorrectly assumes os_name in runenv_from_cpp_info for transitive dependencies

Open ytimenkov opened this issue 3 years ago • 0 comments

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.

  1. 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()
  1. 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"
  1. Create tool package conan create create ./pkg_tool/conanfile.py -pr default
  2. Try to consume without build profile: conan install ./pkg_consumer/ -pr default
  3. Generated conanbuildenv.sh contains only PATH variable set.
  4. Try to consume with build profile: conan install ./pkg_consumer/ -pr:b default
  5. Generated conanbuildenv.sh contains both PATH and LD_LIBRARY_PATH / DYLD_LIBRARY_PATH variables.

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.

ytimenkov avatar Sep 20 '22 04:09 ytimenkov