conan icon indicating copy to clipboard operation
conan copied to clipboard

[bug] Conanfile.py generated in an alias is not compatible with conan 2.0

Open stackfun opened this issue 3 years ago • 3 comments

When creating an alias, I noticed that the generated conanfile.py looks like this

from conans import ConanFile

class AliasConanfile(ConanFile):
    alias = "hello_world/1.0.0@star/cpp#8320d88c7d475c3bb7be9ba562313b36"
    revision_mode = "hash"

However, according to the conan 2.0 migration guide, it states that conanfiles should be using the new import from conan import ConanFile instead (conans => conan). I believe this means that aliases generated in conan 1.x will not be compatible with conan2.x.

Environment Details (include every applicable attribute)

  • Conan version: 1.51.3

stackfun avatar Sep 16 '22 01:09 stackfun

Hi @stackfun

Thanks for reporting, the fix would be quite easy, do you want to give it a try?

Also a note, in 2.0 the conan alias disappear in favor of conan new alias + conan export general commands.

memsharded avatar Sep 16 '22 08:09 memsharded

While working on a PR for this, I noticed that all conanfiles generated by conan new have imports that are not compatible with conan 2.x.

Would you recommend that I address all generated conanfiles in my PR? It may no longer be as simple as changing from conans to from conan. Or should I limit the scope to just fixing the alias since this is my first contribution to the project?

stackfun avatar Sep 16 '22 20:09 stackfun

ould you recommend that I address all generated conanfiles in my PR? It may no longer be as simple as changing from conans to from conan. Or should I limit the scope to just fixing the alias since this is my first contribution to the project?

No, just change the conan alias command. Conan 2.0 has new templates, and also those templates in Conan 1.X have been already superseded by new ones with conan new hello/0.1 -m=cmake_lib, which should already contain the new import. Thanks!

memsharded avatar Sep 18 '22 10:09 memsharded

Closing as outdated.

memsharded avatar Mar 15 '24 22:03 memsharded