You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was going through this documentation: https://docs.conan.io/2/tutorial/versioning/versions.html#automating-versions. I created a version.txt file via echo 1.0.1 > version.txt (I'm on Ubuntu 20.04) and then followed the example of changing the conanfile.py to have the self.version = load(self, "version.txt") and created the conan package. in my downstream library I updated the required version to try it out but much to my surprise it couldn't find the new version of the library.
raptor@b7eb467eb0f0:/workspaces/raptor/react/conan/say (master: )
$ conan create . -s build_type=Release
======== Exporting recipe to the cache ========
say/1.0.1
: Exporting package recipe: /workspaces/raptor/react/conan/say/conanfile.py
say/1.0.1
: Copied 1 '.py' file: conanfile.py
say/1.0.1
: Copied 2 '.txt' files: CMakeLists.txt, CMakeLists.txt
say/1.0.1
: Copied 1 '.h' file: say.h
say/1.0.1
: Copied 1 '.cpp' file: say.cpp
say/1.0.1
: Exported to cache folder: /home/raptor/.conan2/p/sayeb913fded5e3c/e
say/1.0.1
: Exported: say/1.0.1
#0843793d48ad35501914f254a9d4844f (2023-05-10 20:29:04 UTC)
======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=7
os=Linux
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=7
os=Linux
======== Computing dependency graph ========
Graph root
cli
Requirements
say/1.0.1
#0843793d48ad35501914f254a9d4844f - Cache
======== Computing necessary packages ========
say/1.0.1
: Forced build from source
Requirements
say/1.0.1
#0843793d48ad35501914f254a9d4844f:c4735bf28b871912194110fef2bd705f763687fc - Build
======== Installing packages ========
-------- Installing package say/1.0.1
(1 of 1) --------
say/1.0.1
: Building from source
say/1.0.1
: Package say/1.0.1
:c4735bf28b871912194110fef2bd705f763687fc
say/1.0.1
: Copying sources to build folder
say/1.0.1
: Building your package in /home/raptor/.conan2/p/t/saya85b427e070d6/b
say/1.0.1
: Calling generate()
say/1.0.1
: Generators folder: /home/raptor/.conan2/p/t/saya85b427e070d6/b/build/Release/generators
say/1.0.1
: CMakeToolchain generated: conan_toolchain.cmake
say/1.0.1
: CMakeToolchain generated: CMakePresets.json
say/1.0.1
: CMakeToolchain generated: ../../../CMakeUserPresets.json
say/1.0.1
: Generating aggregated env files
say/1.0.1
: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
say/1.0.1
: Calling build()
say/1.0.1
: Running CMake.configure()
say/1.0.1
: RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/raptor/.conan2/p/t/saya85b427e070d6/b/build/Release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/raptor/.conan2/p/t/saya85b427e070d6/p" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/raptor/.conan2/p/t/saya85b427e070d6/b/."
-- Using Conan toolchain: /home/raptor/.conan2/p/t/saya85b427e070d6/b/build/Release/generators/conan_toolchain.cmake
-- Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE=ON (options.fPIC)
-- Conan toolchain: C++ Standard 14 with extensions ON
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_POLICY_DEFAULT_CMP0091
-- Build files have been written to: /home/raptor/.conan2/p/t/saya85b427e070d6/b/build/Release
say/1.0.1
: Running CMake.build()
say/1.0.1
: RUN: cmake --build "/home/raptor/.conan2/p/t/saya85b427e070d6/b/build/Release" -- -j16
[ 50%] Building CXX object CMakeFiles/say.dir/src/say/say.cpp.o
[100%] Linking CXX static library libsay.a
[100%] Built target say
say/1.0.1
: Package 'c4735bf28b871912194110fef2bd705f763687fc' built
say/1.0.1
: Build folder /home/raptor/.conan2/p/t/saya85b427e070d6/b/build/Release
say/1.0.1
: Generating the package
say/1.0.1
: Temporary package folder /home/raptor/.conan2/p/t/saya85b427e070d6/p
say/1.0.1
: Calling package()
say/1.0.1
: Running CMake.install()
say/1.0.1
: RUN: cmake --install "/home/raptor/.conan2/p/t/saya85b427e070d6/b/build/Release" --prefix "/home/raptor/.conan2/p/t/saya85b427e070d6/p"
-- Install configuration: "Release"
-- Installing: /home/raptor/.conan2/p/t/saya85b427e070d6/p/src/say/say.h
-- Installing: /home/raptor/.conan2/p/t/saya85b427e070d6/p/lib/libsay.a
-- Installing: /home/raptor/.conan2/p/t/saya85b427e070d6/p/lib/cmake/say/say-config.cmake
-- Installing: /home/raptor/.conan2/p/t/saya85b427e070d6/p/lib/cmake/say/say-config-release.cmake
-- Installing: /home/raptor/.conan2/p/t/saya85b427e070d6/p/lib/cmake/say/say-config-version.cmake
say/1.0.1
: package(): Packaged 1 '.h' file: say.h
say/1.0.1
: package(): Packaged 1 '.a' file: libsay.a
say/1.0.1
: package(): Packaged 3 '.cmake' files: say-config-release.cmake, say-config.cmake, say-config-version.cmake
say/1.0.1
: Created package revision 0ed0b6f977a0fde7133462655419d92e
say/1.0.1
: Package 'c4735bf28b871912194110fef2bd705f763687fc' created
say/1.0.1
: Full package reference: say/1.0.1
#0843793d48ad35501914f254a9d4844f:c4735bf28b871912194110fef2bd705f763687fc#0ed0b6f977a0fde7133462655419d92e
say/1.0.1
: Package folder /home/raptor/.conan2/p/sayf274a9c3feb6a/p
raptor@b7eb467eb0f0:/workspaces/raptor/react/conan/say (master: )
$ cd ../hello/
raptor@b7eb467eb0f0:/workspaces/raptor/react/conan/hello (master: )
$ conan install . -s build_type=Release
======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=7
os=Linux
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu14
compiler.libcxx=libstdc++11
compiler.version=7
os=Linux
======== Computing dependency graph ========
say/1.0.1: Not found in local cache, looking in remotes...
say/1.0.1: Checking remote: conancenter
Graph root
conanfile.py (hello/1.0.1): /workspaces/raptor/react/conan/hello/conanfile.py
ERROR: Package 'say/1.0.1' not resolved: Unable to find 'say/1.0.1' in remotes.
raptor@b7eb467eb0f0:/workspaces/raptor/react/conan/hello (master: )
$ conan list say
Local Cache
say
say/1.0.0
say/1.0.1
so my consuming app couldn't find the package, but conan list indicated it was present. The issue was that echo 1.0.1 > version.txt inserted a newline in version.txt and that newline was getting pulled into the package version. obvious now that I know what the issue is but not apparent by default.
The solution was a) don't insert a newline in version.txt (i.e. echo -n 1.0.1 > version.txt) or b) strip it in python (i.e. self.version = load(self, "version.txt").strip()
I think it would nice if the load function did that for you, or at a very minimum warned it was inserting a newline into the version number (seems that shouldn't be allowed to begin with).
Have you read the CONTRIBUTING guide?
I've read the CONTRIBUTING guide
The text was updated successfully, but these errors were encountered:
the load() cannot be changed to modify contents of the loaded thing, that would be breaking and problematic. So it is the responsibility of the users to do the right thing
It is true that some unexpected characters shouldn't be allowed in the version via this mechanism, and Conan should be able to throw an error if this happens. I am going to check this.
#13870 will make sure that adding a line feed to the version (or other fields), will make sure to raise an error as an invalid definition (will be in 2.0.5)
What is your suggestion?
I was going through this documentation: https://docs.conan.io/2/tutorial/versioning/versions.html#automating-versions. I created a version.txt file via
echo 1.0.1 > version.txt
(I'm on Ubuntu 20.04) and then followed the example of changing theconanfile.py
to have theself.version = load(self, "version.txt")
and created the conan package. in my downstream library I updated the required version to try it out but much to my surprise it couldn't find the new version of the library.so my consuming app couldn't find the package, but
conan list
indicated it was present. The issue was thatecho 1.0.1 > version.txt
inserted a newline inversion.txt
and that newline was getting pulled into the package version. obvious now that I know what the issue is but not apparent by default.The solution was a) don't insert a newline in version.txt (i.e. echo -n 1.0.1 > version.txt) or b) strip it in python (i.e.
self.version = load(self, "version.txt").strip()
I think it would nice if the load function did that for you, or at a very minimum warned it was inserting a newline into the version number (seems that shouldn't be allowed to begin with).
Have you read the CONTRIBUTING guide?
The text was updated successfully, but these errors were encountered: