conan
                                
                                 conan copied to clipboard
                                
                                    conan copied to clipboard
                            
                            
                            
                        [bug] Conanfile.py generated in an alias is not compatible with conan 2.0
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
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.
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?
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!
Closing as outdated.