-
Notifications
You must be signed in to change notification settings - Fork 790
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
Alias support #523
Comments
Originally posted by @bitwalker in asdf-vm/asdf-elixir#63 (comment)
I'm definitely aware of the correspondence between simple/easy, my point was that as a user, those qualities mean different things than they do as a maintainer. Specifically, with my user hat on the "ease" in which I can avoid using multiple tools to do one thing (version management), and the "simplicity" of something that doesn't use any magic, just simple OS primtives, are the reasons why I chose it.
I'm not convinced that it is as complex as you expect. Supporting options with
I will of course have to investigate to see if there are limitations here, but if that's the case, then if I need to maintain my own shell script to add this capability, I'm not opposed to that idea, but it does seem rather fundamental to Do you have suggestions for tools for alias management? The shell is plainly inadequate for this out of the box, as creating arbitrarily-long lived aliases and destroying them on the fly is not something you get for free.
I think there are two usage patterns, distinct from one another: First is the use you are talking about, where users are installing versions and saving It would be absolutely possible for the
Again, I think it is absolutely possible to deal with this edge case in a sane way, probably by warning when the
This is really the responsibility of the users managing aliases though, just like it would be if they implemented this functionality manually. The benefit of having it in
I use them very frequently when switching between builds with different things I'm testing. Granted, I'm a bit of a special case as a open source maintainer with a lot of projects with a large matrix of languages and versions to work across - but that is precisely why I use
He does that once, and then uses the alias from then onward, which is the point, he only needs to type the verbose command the one time. We can move this discussion to an issue if you'd like, perhaps it would be better to do that so that you can point other users there one way or the other. I don't want to pressure you on this, if you still aren't convinced, then I will find a solution one way or the other, but I had hoped we might find consensus of some kind. |
Specifically, my suggestion was that the The alias would ultimately just be a convenience for the CLI, under the covers the alias is always resolved to the concrete path/ref, and treated normally. Aliases would need to be stored in their own metadata file under This does mean (I think) that one cannot edit As for handling the The main issues raised by @Stratus3D were:
I don't think 1 is too much of an issue, as the implementation is a very thin layer that sits in the command processing bits to resolve an alias to a concrete version (if an alias is defined). It is not necessary to do any extra work in the subcommands as far as I can see. I believe I've addressed both 2 and 3 in my specification of behavior above. In short, aliases are never used except at the CLI, the versions stored in If I've missed something in this design, definitely let me know! |
@bitwalker Thanks for the detailed explanation.
Point 4 makes me think that I am not sure I like the idea of having Overall I don't think this would add too much complexity so if we can settle on a design I would be happy to accept a PR. @asdf-vm/core What are your thoughts about this? |
RE: 4, my intuition around I like the idea of having porcelain commands for alias management, but I would still support EDIT: As an extension of my proposal, I'd suggest something like the following for the alias metadata:
Which can be trivially processed like so: local aliases="$(grep -v '#.*' "${aliases_path}")"
local lang="$(echo "$aliases" | cut -d'|' -f1)"
local name="$(echo "$aliases" | cut -d'|' -f2)"
local concrete_ref="$(echo "$aliases" | cut -d'|' -f3)" |
I'm still not convinced this needs to be part of asdf. I could create a 20 line shell script that does everything you described (and it would work for anything, not just asdf), and it would be simpler than making these changes to asdf itself to support this. Why add complexity? Just create (or use an existing tool) that does this. My two main objections here are:
I'm not denying this would be a useful to you, it no doubt would be. But for the most users it would not be useful, and would create unnecessary clutter in the code and docs. I estimate only about 1-5% of asdf users use |
Related: #499 |
@Stratus3D I'm willing to work on I'm not denying that I could write this feature for myself in shell, but that's fundamentally true of basically the entirety of what I use The argument that one should just do it themselves also kind of ignores the possibility that a lot of people using
I choose tools with the hope that they (ideally) encapsulate the complexity inherent in the task for which they are used. The feature proposed here is fundamentally a solution to a problem with the UX of one part of If my willingness to step in and maintain the feature is insufficient, then I'm willing to accept that this won't make it in to I hope you realize that a tool like that is an absurd level of overkill for the problem being solved in this proposal. Aside from the fact that it requires a Ruby runtime, it doesn't provide a way for one to run function asdf(){
if [ -z "$1" ]; then
command asdf
fi
case "$1" in
install)
lang="$2"
concrete_ver="$3"
args=`getopt a: $*`
set -- $args
for i do
case "$i" in
-a)
named_ver="$2"; shift; shift;
echo "$lang|$named_ver|$concrete_ver" >> ~/.asdf_aliases
;;
--)
shift; break
;;
esac
done
command asdf install "$lang" "$concrete_ver"
;;
local)
command asdf local "$2" "$(lookup_alias "$3")"
;;
*)
# ... other commands here
;;
esac
} I'm not even sure the above works correctly, and leaves |
@bitwalker Thanks a lot for offering to help. I am starting to think this might be a good opportunity to give "non-language plugins" a try. #367 I understand this feature can be useful but I think the number of people needing it is probably fairly low (I don't have data to support this so I might be wrong). @Stratus3D @bitwalker What do you think? |
I think it definitely makes sense being a plugin if the necessary hooks are there, I'll have to read up on whats planned there. |
I don't think we have given much thought into what hooks would be necessary for the plugins yet, so I think this could be a good opportunity to do so. |
I'll chime in over in that thread once I've thought about it for a bit, I have some initial thoughts, but want to check out some assumptions first. |
For anyone interested, I created a standalone shell script called asdf-alias that creates aliases via symlinks and then reshims the plugin (required to work). It is based on nodenv-aliases which is handy to avoid installing every minor version of a runtime. I've been using it for a little while and seems to be working fine in most cases. That said, it's not integrated into I could see something like this integrated into
If there is interest in either option, I'd be willing to attempt a PR. |
@andrewthauer Latest asdf release lets plugins enhance the CLI with additional commands (see extension-commands) So for example, if you have an
And it contains a |
Thanks for pointing that out @vic. I didn't realize that extension commands had been added. I was able to easily port over my So, the bigger question would be, does |
FYI - I created a plugin named asdf-alias. Also created issue #641, to point out some thoughts on extension command only plugins. |
Don't know I'm doing something wrong @andrewthauer, but I can't use your plugin because bin are missing. So I installed asdf-alias, but can't install an alias version and so use it. |
Yeah. I think something either changed in the underlying core API, or I read the docs wrong. I’ve been meaning to fix it, but got sidetracked. I’ll try take a stab at getting it fixed and published properly. In the mean time you could likely take the script code and run the command directly without any changes. |
@andrewthauer If there's improvements to the documentation, please open another issue to share your specific thoughts and tag me 😄 I've got a WIP rewrite of the "creating plugins" section I have been meaning to finish 😅 Plugin author feedback is not only welcome but required. |
@jthegedus - I just debugged through the code of the |
@andrewthauer yes, sounds like another issue for us to tackle |
@jthegedus. Sorry I'm actually wrong, it does look for the plugin commands. I've tracked down the problem. The In my case, I don't' have this directory, so it doesn't bother to look for the sub command. If I add a dummy |
What about having an auto-generated
The user could enable this feature at a plugin level or with a global setting, similar to A common user could bump the specific version by running something like: |
A discussion about aliases has started in asdf-vm/asdf-elixir#63.
As this is not directly related to asdf-elixir but rather to asdf, let's have the discussion here.
I personally only use "regular" versions so I do not have a strong opinion about this but I get the point.
I am not exactly sure how what the
--alias
flag is about though?Could somebody please propose what he thinks would be a good way for asdf to handle aliases?
The text was updated successfully, but these errors were encountered: