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

Use latest version instead of first one #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jhereth
Copy link

@jhereth jhereth commented May 16, 2020

Instead of using the first version among the candidates found take the last one. Since versions are sorted alphabetically this should be the latest installed version.

Yamashita Yuu and others added 3 commits July 26, 2014 13:27
If multiple candidates found in pyenv, display a warning message and
just choose first one for `PYENV_COMMAND_PATH`.
Set `PYENV_COMMAND_PATH` even if multiple candidate versions found.
Instead of using the first version among the candidates found take the last one. Since versions are sorted alphabetically this should be the latest installed version.

Solves concordusapps#3
@jhereth
Copy link
Author

jhereth commented May 16, 2020

This was originally concordusapps#5. Unfortunately, the original maintainers are not responsive.

The original issue is concordusapps#3

@ghost
Copy link

ghost commented Apr 6, 2021

This is much better than the default behavior!

However, it doesn't pick up any versions >= .10 as newest, due to the way the pyenv-whence output is 'sorted'; it sorts just numerically so 3.6.10 comes before 3.6.9 (or even 3.6.2). It seems that pyenv-whence uses a filtered pyenv-versions output, which unfortunately isn't sorted deterministically at all (see: rbenv/rbenv#1086 ).

As a local quick-fix I'm piping the command that generates the versions array through sort --version-sort but it may be better to use sorting like https://github.com/rbenv/ruby-build/blob/00490d341bd2ee3684606397980fe3d82324a0e3/bin/ruby-build#L1182-L1185 (see review comment in rbenv/rbenv#1111 ).

FWIW: I've been using this locally for quite some time now and only found the issue noted above.

@jhereth
Copy link
Author

jhereth commented Apr 11, 2021

@sevens-ef This is true. When I wrote this, 3.8 was the future and it wasn't even clear if there ever would be a 3.10.

Since then a lot of time has passed, the PR is still not merged and I'm not using this myself anymore.

I don't know of any simple approach to do proper version ordering in bash. If anyone wants to take over this proposal please comment and create an improved PR. I'll close this one then.

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.

2 participants