conan icon indicating copy to clipboard operation
conan copied to clipboard

[bug] Conan generator results are not overwritten on a second run

Open oweissbarth opened this issue 1 year ago • 1 comments

Describe the bug

Linux, Ubuntu 22.04, Conan 2.2.3, Python 3.10.12

How to reproduce it

When re-running the install command a second time with different requirements at a later point the conan generator results are not updated.

Run the following commands:

conan install -g CMakeDeps --requires="poco/1.9.4"
conan install -g CMakeDeps --requires="poco/1.13.3"

Afterwards I would expect PocoConfig.cmake to contain information about poco/1.13.3 instead it still contains information about poco/1.9.4.

In PocoConfig.cmake:

[..]
set(Poco_VERSION_STRING "1.9.4")
[..]

See full log below.

Full log
~/conan_install_test   
❯ conan install -g CMakeDeps --requires="poco/1.9.4"

======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu17 compiler.libcxx=libstdc++11 compiler.version=12 os=Linux [conf]

Profile build: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu17 compiler.libcxx=libstdc++11 compiler.version=12 os=Linux [conf]

======== Computing dependency graph ======== Graph root cli Requirements bzip2/1.0.8#411fc05e80d47a89045edc1ee6f23c1d - Cache expat/2.5.0#91e43e4544923e4c934bfad1fa4306f9 - Cache openssl/1.1.1t#55e398751ff5310a8525645c99c81495 - Cache pcre/8.45#64cdfd792761c32817cd31d7967c3709 - Cache poco/1.9.4#f7cfa1f609e6ddef0166efae9d7a479f - Cache sqlite3/3.40.1#c5e96fa97eb3c61b44120e2695f528c9 - Cache zlib/1.2.13#4e74ebf1361fe6fb60326f473f276eb5 - Cache

======== Computing necessary packages ======== Requirements bzip2/1.0.8#411fc05e80d47a89045edc1ee6f23c1d:4530633a3406a354d9c70a71124250144067de22#9a9214178cf9d49820bac01bd07c7253 - Cache expat/2.5.0#91e43e4544923e4c934bfad1fa4306f9:09d00c087ec9c49f97b61c5a54bbeac1efa85f1d#705f9786d744669ca8c9789e8fccf03c - Cache openssl/1.1.1t#55e398751ff5310a8525645c99c81495:3dbf44d5043a2124b7b7670dedfd65ce721f96a2#434234559e6a04b6c0e877eae12fd16a - Cache pcre/8.45#64cdfd792761c32817cd31d7967c3709:92295a7a788424942c3cfe005079f3f47f8a52d8#cd66f7b25e90d21a5322ac2077035f4d - Cache poco/1.9.4#f7cfa1f609e6ddef0166efae9d7a479f:5b627615c5ff5326eb2cac865102e7a2f9275745#2c429146cf8198c62e531235cb5a2474 - Cache sqlite3/3.40.1#c5e96fa97eb3c61b44120e2695f528c9:f38ea0d5445898b826d5977d9204cf9896cd53e0#d49c45deb815e43154379a32e64a6047 - Cache zlib/1.2.13#4e74ebf1361fe6fb60326f473f276eb5:5bc851010eb7b707e5cb2e24cb8ccf0f27989fa9#8ff68b8d2a999d34f0b2a3faa36360a0 - Cache

======== Installing packages ======== bzip2/1.0.8: Already installed! (1 of 7) expat/2.5.0: Already installed! (2 of 7) openssl/1.1.1t: Already installed! (3 of 7) sqlite3/3.40.1: Already installed! (4 of 7) zlib/1.2.13: Already installed! (5 of 7) pcre/8.45: Already installed! (6 of 7) poco/1.9.4: Already installed! (7 of 7) WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X: WARN: deprecated: 'cpp_info.names' used in: zlib/1.2.13, poco/1.9.4, expat/2.5.0, pcre/8.45, sqlite3/3.40.1, bzip2/1.0.8, openssl/1.1.1t WARN: deprecated: 'cpp_info.build_modules' used in: openssl/1.1.1t, bzip2/1.0.8, sqlite3/3.40.1 WARN: deprecated: 'env_info' used in: bzip2/1.0.8, sqlite3/3.40.1, pcre/8.45 WARN: deprecated: 'cpp_info.filenames' used in: poco/1.9.4, sqlite3/3.40.1

======== Finalizing install (deploy, generators) ======== cli: Writing generators to /home/oweissbarth/conan_install_test cli: Generator 'CMakeDeps' calling 'generate()' cli: CMakeDeps necessary find_package() and targets for your CMakeLists.txt find_package(Poco) target_link_libraries(... Poco::Poco) cli: Generating aggregated env files cli: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh'] Install finished successfully

~/conan_install_test
❯ conan install -g CMakeDeps --requires="poco/1.13.3"

======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu17 compiler.libcxx=libstdc++11 compiler.version=12 os=Linux [conf]

Profile build: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu17 compiler.libcxx=libstdc++11 compiler.version=12 os=Linux [conf]

======== Computing dependency graph ======== Graph root cli Requirements bzip2/1.0.8#411fc05e80d47a89045edc1ee6f23c1d - Cache expat/2.6.2#2d385d0d50eb5561006a7ff9e356656b - Cache libmysqlclient/8.1.0#ecca1993f7ce32371ef5436f3639074a - Cache libpq/15.4#cbae5e1ee85bd5e959e039e00307e8b1 - Cache lz4/1.9.4#1217a03c990b79aa34ed0faede18f534 - Cache openssl/1.1.1w#48acccc156e0cd9d775a2ebb4f0aa0ba - Cache pcre2/10.42#74a354d74d291503aadffe6453d976f5 - Cache poco/1.13.3#007642154974b1f81167b7a3581749aa - Cache sqlite3/3.45.0#3a7911478ffd14e7acc694ac113449b6 - Cache zlib/1.2.13#4e74ebf1361fe6fb60326f473f276eb5 - Cache zstd/1.5.5#93372fe14bb7883bd4de82914e0a1841 - Cache Resolved version ranges expat/[>=2.6.2 <3]: expat/2.6.2 openssl/[>=1.1 <4]: openssl/1.1.1w zlib/[>=1.2.11 <2]: zlib/1.2.13

======== Computing necessary packages ======== Requirements bzip2/1.0.8#411fc05e80d47a89045edc1ee6f23c1d:4530633a3406a354d9c70a71124250144067de22#9a9214178cf9d49820bac01bd07c7253 - Cache expat/2.6.2#2d385d0d50eb5561006a7ff9e356656b:09d00c087ec9c49f97b61c5a54bbeac1efa85f1d#123374f07887fcf9952591561d857239 - Cache libmysqlclient/8.1.0#ecca1993f7ce32371ef5436f3639074a:212d63eb944ed08bf9a0c661a7feecbe6e719251#506bfc3ea47fcc760ac87bf2b72cdf2e - Cache libpq/15.4#cbae5e1ee85bd5e959e039e00307e8b1:5d9c4c73c13f2780ef163cdd8d5c9b84b129bd49#8b907a824c27e2427f31dc0317ca20e5 - Cache lz4/1.9.4#1217a03c990b79aa34ed0faede18f534:5bc851010eb7b707e5cb2e24cb8ccf0f27989fa9#c532648e4378c750f86be01cb143e82a - Cache openssl/1.1.1w#48acccc156e0cd9d775a2ebb4f0aa0ba:3dbf44d5043a2124b7b7670dedfd65ce721f96a2#ca6253e6354ce3577a5d324d90f99d63 - Cache pcre2/10.42#74a354d74d291503aadffe6453d976f5:abe43bf6bc44e57134deaf79b8834d3deb578fd1#114c38cfef13b206899de42294d38d50 - Cache poco/1.13.3#007642154974b1f81167b7a3581749aa:e401f033d544baa563f800d3c45d513df49282f3#010a49f2e9b426369485aba20a060a91 - Cache sqlite3/3.45.0#3a7911478ffd14e7acc694ac113449b6:f38ea0d5445898b826d5977d9204cf9896cd53e0#9b821ee034ba798448b57ebec61d27d7 - Cache zlib/1.2.13#4e74ebf1361fe6fb60326f473f276eb5:5bc851010eb7b707e5cb2e24cb8ccf0f27989fa9#8ff68b8d2a999d34f0b2a3faa36360a0 - Cache zstd/1.5.5#93372fe14bb7883bd4de82914e0a1841:950eb44845a30cbb22c66873cfcbc02c4ad041e2#8bc887bdd48970c56eab27d623c752c2 - Cache

======== Installing packages ======== bzip2/1.0.8: Already installed! (1 of 11) expat/2.6.2: Already installed! (2 of 11) libpq/15.4: Already installed! (3 of 11) lz4/1.9.4: Already installed! (4 of 11) openssl/1.1.1w: Already installed! (5 of 11) sqlite3/3.45.0: Already installed! (6 of 11) zlib/1.2.13: Already installed! (7 of 11) zstd/1.5.5: Already installed! (8 of 11) libmysqlclient/8.1.0: Already installed! (9 of 11) pcre2/10.42: Already installed! (10 of 11) pcre2/10.42: Appending PATH environment variable: /home/oweissbarth/.conan2/p/pcre29113ac6da6e0c/p/bin poco/1.13.3: Already installed! (11 of 11) WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X: WARN: deprecated: 'cpp_info.names' used in: zstd/1.5.5, libmysqlclient/8.1.0, pcre2/10.42, sqlite3/3.45.0, libpq/15.4, openssl/1.1.1w, expat/2.6.2, bzip2/1.0.8, zlib/1.2.13, poco/1.13.3, lz4/1.9.4 WARN: deprecated: 'cpp_info.build_modules' used in: bzip2/1.0.8, openssl/1.1.1w, sqlite3/3.45.0, lz4/1.9.4 WARN: deprecated: 'env_info' used in: bzip2/1.0.8, libpq/15.4, pcre2/10.42, sqlite3/3.45.0 WARN: deprecated: 'cpp_info.filenames' used in: sqlite3/3.45.0, poco/1.13.3

======== Finalizing install (deploy, generators) ======== cli: Writing generators to /home/oweissbarth/conan_install_test cli: Generator 'CMakeDeps' calling 'generate()' cli: CMakeDeps necessary find_package() and targets for your CMakeLists.txt find_package(Poco) target_link_libraries(... Poco::Poco) cli: Generating aggregated env files cli: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh'] Install finished successfully

~/conan_install_test
❯ cat PocoConfig.cmake
########## MACROS ########################################################################### #############################################################################################

Requires CMake > 3.15

if(${CMAKE_VERSION} VERSION_LESS "3.15") message(FATAL_ERROR "The 'CMakeDeps' generator only works with CMake >= 3.15") endif()

if(Poco_FIND_QUIETLY) set(Poco_MESSAGE_MODE VERBOSE) else() set(Poco_MESSAGE_MODE STATUS) endif()

include(${CMAKE_CURRENT_LIST_DIR}/cmakedeps_macros.cmake) include(${CMAKE_CURRENT_LIST_DIR}/PocoTargets.cmake) include(CMakeFindDependencyMacro)

check_build_type_defined()

foreach(_DEPENDENCY ${poco_FIND_DEPENDENCY_NAMES} ) # Check that we have not already called a find_package with the transitive dependency if(NOT ${_DEPENDENCY}_FOUND) find_dependency(${_DEPENDENCY} REQUIRED ${${_DEPENDENCY}_FIND_MODE}) endif() endforeach()

set(Poco_VERSION_STRING "1.9.4") set(Poco_INCLUDE_DIRS ${poco_INCLUDE_DIRS_RELEASE} ) set(Poco_INCLUDE_DIR ${poco_INCLUDE_DIRS_RELEASE} ) set(Poco_LIBRARIES ${poco_LIBRARIES_RELEASE} ) set(Poco_DEFINITIONS ${poco_DEFINITIONS_RELEASE} )

Only the first installed configuration is included to avoid the collision

foreach(_BUILD_MODULE ${poco_BUILD_MODULES_PATHS_RELEASE} ) message(${Poco_MESSAGE_MODE} "Conan: Including build module from '${_BUILD_MODULE}'") include(${_BUILD_MODULE}) endforeach()

oweissbarth avatar May 16 '24 10:05 oweissbarth

Hi @oweissbarth

Thanks very much for your detailed report.

It is true that Conan was doing something unexpected there, caching the previously existing xxxxConfig.cmake file to preserve previous variable definitions. It is not fully clear why it was there, I am trying to remove it in a draft PR https://github.com/conan-io/conan/pull/16279 and see if something break, and understand potential issues.

memsharded avatar May 16 '24 12:05 memsharded

https://github.com/conan-io/conan/pull/16279 was merged, it will be in next Conan 2.4, thanks again!

memsharded avatar May 28 '24 16:05 memsharded

Thanks for fixing this!

oweissbarth avatar Jun 06 '24 20:06 oweissbarth

Happy to help, thanks to you for the feedback!

memsharded avatar Jun 07 '24 06:06 memsharded