I have some thoughts on making the conan alias more useful.
conan alias 1.2.latest MyPkg/1.2.5@demo/stable-r artifactory which will upload the alias to the specified remote automatically without the need to run another command (conan upload)To help us debug your issue please explain:
Hi @sunj1!
Thanks a lot for your proposal
I think when you are using the alias feature you want to be as explicit as possible to now exactly what you are actually aliasing. To me, taking automatically the rest of the reference is too complex for low value.
Also, having a -r means mixing the purpose of this command and conan upload, so I am not sure about it.
Thanks for taking a look @danimtb .
I think when you are using the alias feature you want to be as explicit as possible to now exactly what you are actually aliasing. To me, taking automatically the rest of the reference is too complex for low value.
From what I understand, Aliasing is visible/applicable only within a channel for a user.
If so, it is always required that the package-name, user and channel be exactly the same.
In a way, it looks like the same set of information is repeated in two parameters for a same function, doesn't it?
Also, having a
-rmeans mixing the purpose of this command andconan upload, so I am not sure about it.
Yes it may look like it at the first glance.
This is probably because the upload function existed prior to implementing the alias function.
To me as a conan user, it (conan alias) would look more natural like the conan remove command. If we do not specify -r remote, then the command executes in local cache. Whereas, if I specify the -r remote, then it is executed on the remote server (which is why the need to check that the target reference recipe actually exists on the server).
You can change the version, the user and the channel but not the name of the package (not sure why but that is another discussion IMO).
Regarding -r flag, I still think it should be done in two steps and I dont think it is the same thing as the conan remove -r. You may want an alias only locally and not in server and the upload it. Following that rule, conan create should also have a -r but I think having the logic in different commands is the best way to go.
Summary: I agree the alias command may need a review regarding parameters of CLI in references (name/version@user/channel) for example to use a different name. but I don't think there is a need to add more complexity to the logic behind (Checks could be something useful but -r will be confusing)
You can change the version, the user and the channel but not the name of the package (not sure why but that is another discussion IMO).
Thanks for the clarification here.
I think this behavior should be updated in the documentation as well, so users can make use of this feature.
So now, only the "target validation check" makes sense.
I have been checking this issue and I think as the feature of alias is totally decoupled from the server the implemetation of the --checks flags is not trivial.
However, while doing some tests with the alias command lines I found some usability issues:
$ conan alias opencv/1.2@/danimtb/testing opencv/3.4.3@danimtb/testing
ERROR: Value provided for user name, '' (type str), is too short. Valid names must contain at least 2 characters.
Users cannot benefit from information about alias in commands such as conan inspect or conan search. Specially conan search does not give any hint about that recipe being an alias.
Behavior is a bit unclear in the documentation and it should be stated the things that can be done and the ones that cannot be done: https://docs.conan.io/en/latest/reference/commands/misc/alias.html
User can create an alias to a non-exisiting package (not existing in cache and nor in server). Performing a check would be useful to prevent a user error but making that check locally will force to have the "aliased" (target) package downloaded in cache or check for it in a server. However, the alias recipe could be checked locally with an existing package and then uploaded to a server where the "aliased" (target) recipe does not exist. I think the best we could try to do is printing a warning here and asume the user knows what they is doing.
Proposal 馃棐: Review the alias command UX and output, improve the documentation with the behavior, study possible --check and print a warning in case the aliased reference is missing locally
I would like to introduce a recent case related to alias that could be part of this issue as improvement.
Catchorg recently released Catch2/2.5.0@catchorg/stable on Conan center and now it became the official provider for Catch2 package, that means catch2/2.5.0@bincrafters/stable must be deprecated. However, alias is case-sensitive and doesn't work when trying to point catchorg as target:
conan alias catch2/2.5.0@bincrafters/stable Catch2/2.5.0@catchorg/stable
Also, you could try just an alias recipe and exporting it, but doesn't work too:
from conans import ConanFile
class AliasConanfile(ConanFile):
alias = "Catch2/2.5.0@catchorg/stable"
conan export . catch2/2.5.0@bincrafters/stable
conan install catch2/2.5.0@bincrafters/stable
The error is the same:
Traceback (most recent call last):
File "/opt/miniconda3/lib/python3.6/site-packages/conans/client/command.py", line 1428, in run
method(args[0][1:])
File "/opt/miniconda3/lib/python3.6/site-packages/conans/client/command.py", line 298, in create
test_build_folder=args.test_build_folder)
File "/opt/miniconda3/lib/python3.6/site-packages/conans/client/conan_api.py", line 89, in wrapper
return f(*args, **kwargs)
File "/opt/miniconda3/lib/python3.6/site-packages/conans/client/conan_api.py", line 381, in create
test_build_folder, test_folder, conanfile_path)
File "/opt/miniconda3/lib/python3.6/site-packages/conans/client/cmd/create.py", line 40, in create
test_build_folder=test_build_folder)
File "/opt/miniconda3/lib/python3.6/site-packages/conans/client/cmd/test.py", line 41, in install_build_and_test
keep_build=keep_build)
File "/opt/miniconda3/lib/python3.6/site-packages/conans/client/manager.py", line 78, in install
self._recorder, None)
File "/opt/miniconda3/lib/python3.6/site-packages/conans/client/graph/graph_manager.py", line 133, in load_graph
processed_profile=processed_profile)
File "/opt/miniconda3/lib/python3.6/site-packages/conans/client/graph/graph_manager.py", line 204, in _load_graph
graph = builder.load_graph(root_node, check_updates, update, remote_name, processed_profile)
File "/opt/miniconda3/lib/python3.6/site-packages/conans/client/graph/graph_builder.py", line 43, in load_graph
dep_graph.compute_package_ids()
File "/opt/miniconda3/lib/python3.6/site-packages/conans/client/graph/graph.py", line 179, in compute_package_ids
conanfile.requires[nref.name].conan_reference = nref
KeyError: 'Catch2'
ERROR: 'Catch2'
The full log is available here
My request here is to support an alias that is not case-sensitive.
Or with other words: The alias resolving should stay case-sensitive but it should allow providing aliases which have the same name but different cases
That's it, thanks @Croydon :smile_cat:
Today, I've just come across a different issue related to aliases. Packaging AWS Lambda for C++ I found more convenient naming the package aws-lambda-runtime than aws-lambda-cpp as the former one is the name of the target inside CMake, the name of the library,...
It would be useful to create an alias to a different package name. I would vote for restrictions on the command line (like it is now), but to give more freedom if the alias conanfile.py is created by hand (the alternative I have is creating a repackaging: python_requires + build_requires).
Most helpful comment
I have been checking this issue and I think as the feature of alias is totally decoupled from the server the implemetation of the
--checksflags is not trivial.However, while doing some tests with the alias command lines I found some usability issues:
Users cannot benefit from information about alias in commands such as
conan inspectorconan search. Speciallyconan searchdoes not give any hint about that recipe being an alias.Behavior is a bit unclear in the documentation and it should be stated the things that can be done and the ones that cannot be done: https://docs.conan.io/en/latest/reference/commands/misc/alias.html
User can create an alias to a non-exisiting package (not existing in cache and nor in server). Performing a check would be useful to prevent a user error but making that check locally will force to have the "aliased" (target) package downloaded in cache or check for it in a server. However, the alias recipe could be checked locally with an existing package and then uploaded to a server where the "aliased" (target) recipe does not exist. I think the best we could try to do is printing a warning here and asume the user knows what they is doing.
Proposal 馃棐: Review the alias command UX and output, improve the documentation with the behavior, study possible
--checkand print a warning in case the aliased reference is missing locally