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

fix: support latest with filter on local and global #633

Merged
merged 22 commits into from Jul 6, 2021

Conversation

klane
Copy link
Contributor

@klane klane commented Jan 5, 2020

Summary

This PR extends the feature added in #575 to asdf global and asdf local. Users can now specify the global or local version of a tool as the latest installed version.

asdf global python latest
asdf local python latest
asdf local python latest:3.7

It also adds the ability to filter installed versions with asdf list:

# only list installed versions of Python 3.7
asdf list python 3.7

@zhengpd
Copy link

zhengpd commented Mar 15, 2020

CI failed and branch conflicts. I like this feature.

@vic
Copy link
Contributor

vic commented Mar 15, 2020

Hi @klane, could you please rebase with master ? :)

@klane
Copy link
Contributor Author

klane commented Mar 16, 2020

Will do @vic. I was affected by #634 and haven't had a chance to revisit this. I should be able to resolve the conflicts this weekend if not sooner.

@klane
Copy link
Contributor Author

klane commented Mar 23, 2020

While it may not have been this weekend, I rebased with master and fixed the merge conflicts. It took me far longer than I care to admit to notice that a variable was renamed.

I'm not sure why the Unix tests would pass on Ubuntu and fail on macOS, particularly since they pass locally on my Mac. Any suggestions are welcomed.

lib/utils.bash Outdated Show resolved Hide resolved
@klane klane requested a review from a team as a code owner May 13, 2020 23:35
@lkraider
Copy link

lkraider commented May 21, 2021

Meanwhile I am using:
asdf local python $(asdf latest python)

Would be useful to support .tool-versions with content such as:

python latest

@jthegedus
Copy link
Contributor

jthegedus commented May 27, 2021

@lkraider We only want exact versions in .tool-versions. This PR will allow using global|local with latest to set the version, but it's just a utility to compute the latest and insert it without having to first look it up.

I will work on re-basing this unless someone beats me to it.

@hoov
Copy link

hoov commented Jun 4, 2021

I found this because I've had a comment in my ~/.tool-versions for a while ago that relates. While I 100% agree that from a local point of view, it makes sense to always require the explicit version number -- otherwise there's no real point. However, from a global point of view, I want to be able to say "always use the latest 3.9.x version of Python". When I start a new project, that's when I'll freeze the version of Python for that project.

This is even more true given the large number of other tools supported by asdf today. In particular, tools like bat, yq, and even tmux. I was excited when I saw things like this added as plugins, because my use case is having later versions than are provided by a release of Debian. Being able to say "use the latest 3.2.x release of tmux globally" is really handy. It's extra useful because then I can use the same tooling to keep my MacOS system up-to-date, rather than having a split between homebrew and asdf. Perhaps the addition of these extra plugins stretched the use of asdf beyond what it should be used for.

@jthegedus
Copy link
Contributor

@hoov

Perhaps the addition of these extra plugins stretched the use of asdf beyond what it should be used for.

Yes, I think this has become the case. While we won't stop people from creating plugins for whichever tools they like, asdf is a version manager, not a system package manager. We do support system as a version for fallthrough reasons so you can have a non-asdf version managed however you wish for your general system usage. I think the usage you're trying to achieve is extremely difficult, otherwise package managers like Homebrew would have added version managing at the directory level long ago.

Comment on lines +52 to 56

if ! (check_if_version_exists "$plugin_name" "$version"); then
version_not_installed_text "$plugin_name" "$version" 1>&2
exit 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check_if_version_exists handles the ref:<ref> & path:<dir> filters two calls deeper in the stack. Those I feel should be elevated to this level as latest:<filter> is handled here.

Copy link
Contributor

@jthegedus jthegedus Jul 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not suggestion we do this now, but this codebase is becoming spaghetti as everything gets pushed down into utils.bash

@jthegedus jthegedus changed the title Add support for using the latest installed version of a tool fix: support latest with filter on local and global Jul 6, 2021
@jthegedus jthegedus merged commit 5cf8f89 into asdf-vm:master Jul 6, 2021
jthegedus added a commit that referenced this pull request Jul 8, 2021
jthegedus added a commit that referenced this pull request Jul 8, 2021
@klane klane deleted the use-latest branch July 15, 2021 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants