This is an issue I've ran into while trying to upgrade to conan 1.18.1 from 1.4.4. I'm observing different behavior in conan 1.18.1 which breaks some of our recipes.
We have a pkg-config helper, which populates PKG_CONFIG_PATH with paths to the .pc files in the required packages. This is done by iterating self.deps_cpp_info.libpaths (which is where we store the .pc files).
Our ffmpeg package hides its dependencies via build_requires (this is highly desirable for us because of the various different ways we use this package). Dependencies of ffmpeg are build_requires. Transitive dependencies (the dependencies of ffmpeg's direct deps) are normal requires.
If I newly build ffmpeg via conan create --build, I see that transitive dependencies don't show up in deps_cpp_info.libpaths. This is different between conan 1.4.4 and 1.18.1.
I have created a full isolated example that can be ran with 1.4.4 and 1.18.1 automatically: https://github.com/sztomi/transitive_br_deps_cpp_info (see instructions in the README there).
The 1.18.1 branch fails with KeyError on this line in the harfbuzz package:
print(self.deps_cpp_info["zlib"].lib_paths)
zlib is a transitive dependency of a transitive dependency of ffmpeg. Notably, the same line doesn't fail if the key is freetype2 which is a direct dependency of harfbuzz.
The relationships between the packages in that repo approximate our real-world graph. It's likely that not all of them are needed for a truly minimal example, but I had to experiment a lot to arrive at this setup which can reproduce it. I'm copying the repro.sh script here for ease of access:
#! /usr/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
pkgs=(ffmpeg fontconfig freetype2 harfbuzz zlib)
ns="tamas/repro"
export CONAN_USER_HOME=$DIR/conan_cache
rm -rf $CONAN_USER_HOME
for pkg in "${pkgs[@]}"; do
pushd $pkg
conan export . $ns
popd
done
cd ffmpeg
conan create . $ns --build missing
So basically, the script
--build missingLittle addition: this is probably not limited to deps_cpp_info. The transitive-transitive deps are completely missing, e.g. if a target links to bzip2 that it used to get access to from a package some levels deeper, it will fail with the new version. I can add the "missing" deps directly to the packages and that works, but it's a somewhat awkward workaround especially for conditional deps.
Hi!
I am having a look to this issue. I was able to reproduce it, thanks very much for the reproducible example.
This is indeed a bug, and zlib information should be there. The bad news is that the underlying cause is the unplanned use of build_requires to link libraries (not for tools), and seems a bit complicated and risky to fix, specially for a minor release, so it might require more effort in next releases. I'll keep working on this and report. Thanks!
Thanks! We are fine with our workaround for the time being.
Verified that #5886 fixes this issue, the https://github.com/sztomi/transitive_br_deps_cpp_info repo works with this fix and fails without it. Really useful, thanks very much @sztomi !!!
Happy to help!