Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in consuming dependencies using Conan 2.0 #12542

Closed
mkjkec2005 opened this issue Nov 15, 2022 · 8 comments
Closed

Error in consuming dependencies using Conan 2.0 #12542

mkjkec2005 opened this issue Nov 15, 2022 · 8 comments
Assignees

Comments

@mkjkec2005
Copy link

mkjkec2005 commented Nov 15, 2022

We had a simple component build consuming Conan packages using Conanfile.txt. This was working with Conan version 1.54. After upgrading to Conan version 2.0.0-beta5, conan install command is failing as below.

$ conan install .. --profile=temp

ERROR: Error while parsing [options] in conanfile
Options should be specified as 'pkg:option=value'

-------- Input profiles --------
Profile host:
[settings]
arch=x86_64
compiler=gcc
compiler.cppstd=14
compiler.libcxx=libstdc++11
compiler.version=8
os=Linux

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

ERROR: Error while parsing [options] in conanfile
Options should be specified as 'pkg:option=value'

$ cat ../conanfile.txt
[requires]
grpc/1.30@FTA/testing
protobuf/3.14.0@FTA/testing
openssl/1.1.1d
rapidjson/1.1.0

[generators]
cmake

[options]
openssl:shared=True

Profile temp:
$ cat temp
[settings]
os=Linux
arch=x86_64
compiler=gcc
compiler.version=8
compiler.libcxx=libstdc++11
compiler.cppstd=14
[conf]

Could you please help to understand what is the issue?

@memsharded memsharded self-assigned this Nov 15, 2022
@memsharded
Copy link
Member

Quick feedback:

[generators]
cmake

The cmake generator has been removed in 2.0. It is necessary to use CMakeDeps and CMakeToolchain. They are available in 1.X, so the recommendation is to upgrade first in 1.X, then upgrading to 2.0 would be easier.

I think the message might not be very informative, could you please try to specify openssl*:shared=True instead?

@mkjkec2005
Copy link
Author

Sure, we will try to use CMakeDeps and CMakeToolChain in 1.x first.

After changing to openssl*, build has moved forward. What difference did * make?

Also, now the build is failing with the below error.

-------- Computing dependency graph --------
grpc/1.30@FTA/testing: Not found in local cache, looking in remotes...
grpc/1.30@FTA/testing: Checking remote: conan-infinera
grpc/1.30@FTA/testing: Trying with 'conan-infinera'...
Downloading conanmanifest.txt
Downloading conanfile.py
grpc/1.30@FTA/testing: Downloaded recipe revision af823dcec02d2e83153ab138fe4a64b9
Graph root
conanfile.txt: /home/dibm/g4x-fast-telemetry-agent/conanfile.txt
Graph error
Package 'grpc/1.30@FTA/testing' not resolved: grpc/1.30@FTA/testing: Cannot load recipe.
Error loading conanfile at '/home/dibm/.conan2/p/8d1a5852211f5bb8/e/conanfile.py': Unable to load conanfile in /home/dibm/.conan2/p/8d1a5852211f5bb8/e/conanfile.py
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/dibm/.conan2/p/8d1a5852211f5bb8/e/conanfile.py", line 1, in
from conans import ConanFile, tools
ImportError: cannot import name 'ConanFile' from 'conans' (/home/dibm/.local/lib/python3.7/site-packages/conans/init.py)

-------- Computing necessary packages --------
ERROR: Package 'grpc/1.30@FTA/testing' not resolved: grpc/1.30@FTA/testing: Cannot load recipe.
Error loading conanfile at '/home/dibm/.conan2/p/8d1a5852211f5bb8/e/conanfile.py': Unable to load conanfile in /home/dibm/.conan2/p/8d1a5852211f5bb8/e/conanfile.py
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "/home/dibm/.conan2/p/8d1a5852211f5bb8/e/conanfile.py", line 1, in
from conans import ConanFile, tools
ImportError: cannot import name 'ConanFile' from 'conans' (/home/dibm/.local/lib/python3.7/site-packages/conans/init.py)

@memsharded
Copy link
Member

After changing to openssl*, build has moved forward. What difference did * make?

Conan 2.0 has normalized and standardized a bit better the pattern matching that happens for package names. If the reference is not complete, like pkg/version, then it is necessary to explicitly say it is a pattern, so it will match any possible openssl version

from conans import ConanFile, tools

Yes, that failure is expected. Conan 2.0 uses only from conan and not from conans. The from conan space is also available in Conan 1.X, check: https://docs.conan.io/en/latest/migrating_to_2.0/recipes.html#python-import-statements

@mkjkec2005
Copy link
Author

I am merely using conanfile.txt. There is no conanfile.py.

@memsharded
Copy link
Member

I am merely using conanfile.txt. There is no conanfile.py.

Your dependencies are: from conans import ConanFile, tools
You cannot use dependencies that are not 2.0 ready. Most of ConanCenter are still not there, you can only use deps created with Conan 2.0, you can have a look to the first important note in https://docs.conan.io/en/2.0/tutorial/consuming_packages/build_simple_cmake_project.html

@mkjkec2005
Copy link
Author

Looks like very few packages are migrated to Conan 2.0. For instance, we use rapidjson and OpenSSL, and those are not converted yet. Do we have a plan in place for conversion?

@memsharded
Copy link
Member

You can check the status in conan-io/conan-center-index#12888. Still binaries are not being uploaded to ConanCenter. The best is to test and report recipe issues to the https://github.com/conan-io/conan-center-index repo.

@AbrilRBS
Copy link
Member

Closing this as solved, CCI is almost 100% compatible with v2 and binaries have ben uploaded for over a year, feel free to reopen/create a new issue should you have any other questions or requests, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants