Closed eprozium closed 3 years ago
Please refrain from using Github issues for usage questions. Use the Gitter user-issues chat instead.
@marc0der it's not a usage question :) .
Sorry for sounding harsh, that was not the intention. The website usage page clearly states that the command to use here is sdk current
.
Thank you very much. Not sure how I missed that one :( .
Thanks, helped me as well. Intuitively I also went for sdk list --installed
or something like that.
Probably a good thing to consider changing sdk list, to sdk available. 1 makes more sense, and 2 that frees you up for using sdk list to show the list of installed. sdk current isn't exactly clear on what it does in its name as sdk list would be for showing all installed. Better yet, get rid of sdk current and just add a sdk list --installed. Probably even better.
@btassone apologies for never replying on this but don't think I ever got notified about your comment.
I agree that renaming list
to available
would make a lot of sense. It would however be very confusing for all our long-time users though.
Regarding the other suggestion of qualifying sdk list
with a --installed
flag, I don't think this is a good idea as it goes against the command syntax of sdkman. We don't use flags like this anywhere else. The syntax always (strictly) falls into the pattern:
sdk <command> [version] [qualifier]
If we introduce something better or more intuitive it should fall into the same pattern.
In other words, sdk list installed
would fall into this pattern, but then what does sdk list
do if we rename it to available
?
My suggestion that we bring about such change in small steps: Leave sdk list
to be what it currently is for the time being, then introduce the installed
qualifier on top of the list
command to replace current
. wdyt?
I think the last suggestion sounds best. "sounds" meaning the way it reads or is spoken. so sdk list installed
and sdk list available
reads nice and looks intuitive. sdk list
could stay the same for some time and then change or simply point to the other statements.
was this ever done? - confused me for a bit this AM before some googling lol
@tb582 no, still waiting for the pull requests to come in :laughing:
@lcxw the beauty of open source is that you can contribute a solution.
sdk list
could continue as an alias for sdk available
. sdk installed
could implement the new functionality. I don't see a need to insert list
after sdk
and before available|installed
.
I've installed several javas, how can I list them all with their paths? The 'sdk current' shows only the current one.
The only way I've found is:
sdk list java | grep installed
Hope that helps
Unless I'm missing something, sdk current
only shows the currently active JDK version.
It doesn't list all the installed versions.
As per @ibethencourt answer, this is the only way (AFAIK) for checking all currently installed versions, which I'd love to have in SdkMan itself!
If I'm missing something please correct me. Have a nice day!
I don't think it's an issue rather than inprovment. As @ibethencourt saying, sdk list java | grep installed is such a good way to solve the issue.
This doesn't work if you want to see all candidates their installed versions.
So I resorted to this:
➜ tree -L 2 ~/.sdkman/candidates/
/home/aairey/.sdkman/candidates/
└── gradle
├── 6.4
└── current -> /home/aairey/.sdkman/candidates/gradle/6.4
3 directories, 0 files
This works as long as you use the default local-path
for your candidates.
added this into my .zshrc
sdkman() {
[[ "$1" == "installed" ]] && sdk list $2 | grep installed || sdk "$@"
}
now i can run sdkman installed java
works great
Stumbled here because I was searching for something similar. I have 4 jdk's installed for different purposes. so when I wanted to switch between, for example jdk 8 to jdk 11, I always forget the exact identifier, "11.0.7.hs-adpt" So I was hoping there was some command which just list just the installed java instead of entire list which require me to scroll up and search for the correct identifier.
This would also be useful in uninstalling redundent/unneeded versions. We can list the installed kotlin and with information in front of us we can type commands easily.
I am surprised this isn't readily available since the list of sdk and jdk has gotten really large. An ideal case would be something like sdk switch java, which would show an alternatives like menu to switch java version.
@Abhinav1217: If you use zsh, oh-my-zsh has command line argument completion for sdkman.
Commands that only work with installed versions will only display / autocomplete installed versions.
I don’t know if sdkman argument completion exists for bash, or how well any such argument completion works.
I am on primarily bash, But I have omz installed I can switch to it temporarily. Currently I set sdkman to offline to limit the list to installed only.
Hi Guys from 2020. Is there a SDKMAN command that list all locally installed packages or it is better to back to the question in 2021 or 2022 ?
@barmalei Not yet. Best I usually work with is set sdkman to offline and then list Java, It shows only installed versions, making it easier to switch. I did create a script for sdkman to do it automatically, but I usually ends up typing whole set as I distro-hop quite frequently.
+1
I use shell autocompletion with sdk use
and it works well for me to see what versions are installed. Review https://github.com/sdkman/sdkman-cli/issues/83 to see how to enable it for your favorite shell
The official sdk
plugin for zsh is already available in your ohmyzsh installation.
Just enable it in your plugins list .zshrc
file and restart the terminal.
plugins=(sdk)
Hi!
With Bash completion now in place, we could display the list of installed candidates when autocompleting the use
command.
That way we wouldn't need to introduce another command only for showing installed versions. @marc0der wdyt?
I came up with a pretty geek solution myself by means of a proxy function for the sdk
command:
function sdk_proxy {
if (( $# == 2 )) && [[ $1 =~ ^(u|use)$ ]]; then
sdk use $candidate $(sdk_fuzzy_find_local_version $2)
else
sdk "$@"
fi
}
(The exact mechanism for turning the above into a proxy function in bash is irrelevant here but you can check out https://frederic-hemberger.de/articles/speed-up-initial-zsh-startup-with-lazy-loading/ in case you're interested).
The snippet above just says that whenever I invoke the use subcommand followed by a candidate BUT NOT a version (i.e. sdk use java
or sdk u java
) then I plug in a custom fuzzy search:
function sdk_fuzzy_find_local_version {
__sdkman_build_version_csv $1 |
tr ',' '\n' |
sort -r -n |
fzf -d '\.' --nth 1
}
I know this is a bit fragile as I'm relying on an internal sdkman function (named __sdkman_build_version_csv
) that is bound to change (or be gone) in the future. But, after all, this is just a workaround and besides I ❤️ proxies ¯_(ツ)_/¯
@helpermethod is it worth keeping this issue open until we have a working solution for ZSH too?
@mperezi very cool, and it must have been fun doing this :smile: However, I certainly would recommend that you use the command line completion that @helpermethod just implemented instead. I'll also look at doing the same for ZSH soon.
Re-opening this issue until ZSH is also supported. This will involve porting the oh-my-zsh plugin back into our completion mechanism.
@marc0der Yes, we should keep the issue open. I can take a stab at ZSH this evening, but I also wouldn't be to sad if anyone else takes over the ZSH completion part 😄.
I can have a crack at it sometime, you've already done ample with bash completion.
The autocompletion functionality is now available for both bash and ZSH. It was released as v5.11.1.
For zsh I cannot get shell completion enabled from using the instructions: https://sdkman.io/usage#completion
I tried them as-is as well as replacing bash
with zsh
.
Hi @franco-circleup, it seems an error has sneaked into the docs.
The correct command is
source <(sdk completion bash)
or for zsh
source <(sdk completion zsh)
I'll fix the documentation tomorrow. Sorry for the inconvenience!
That works perfectly, thanks!
I have enabled completion, But I only get completion for first parameter.
sdk
, double tap the tab key.use
then type java
What is expected
Hi @Abhinav1217,
works fine for me. Are you using the bash
or zsh
completion? Note that use
will only complete the locally installed versions, not all Java versions available.
I am using bash completion, I updated sdk and recreated sdk completion, It did not work. Then based on someone's advice on reddit,
source <(sdk completion bash)
sdk completion bash >> 00_sdkman_bash_completion
in terminal~/.bashrc
Reason given was that sometimes, sdkman prints broadcast messages which will make completion fails. I stumbled upon it as I was occasionally getting this issue whenever I launch new terminal. Which I suspected was something to do with sdk completion but wanted to be sure before I come here.
When I created the 00_sdkman_bash_completion file, I did find the broadcast message in the output. I removed it issue was gone, Only downside is that now I would have to manually update the completion file from time to time.
This issue is resolved for me, unless broadcast message should not have been printed when subcommand is completion. In that case, I have no idea why I got it.
Hi @Abhinav1217, we are already aware of this issue and tracking it in #912. We should have a fix out for this soon. In the meanwhile, please source the completion file directly from your profile rather than using the completion command.
Sorry to resurrect this issue that started rather unfortunate.
I'm a fish
shell user and hence only got to use sdk!man by omf i sdk
. I stumbled over exact the same issue as OP, and after scrolling through this issue I feel that it is still open and very relevant. Even more: I still don't know how to achieve my query!
For illustration. This is what i.e. omf
tells you after simply typing omf
:
I immediately understand: omf l
is the way to go.
I was really strained looking at the sdk
output:
sdk current
at least reveals some of the installed candidatessdk list | grep installed
does not list any hits at allI'd still propose, that this issue is still relevant and an easy command to the list the locally installed packages should be offered and easily discoverable from the CLI.
I feel that should not need to become a shell programming expert or documentation archaeologist to fulfil this task… For me this sounds like a very, very easy and task and undoubtedly relevant functionality. Anybody willing to explain me the backgrounds for this discussion which is ongoing for more than five years?
I agree with @bentolor What's the expectation of the maintainers? For the cimmunity to create a fork just for the sake of one useful feature that is very very easy to implement without any risk for the existing functionality? (e.g. add an explicit command)
still no way to list the installed versions?
I solved it by sdk list java|grep installed
It works but it's workaround...
Also I have some installs that have the label "local only", so I have to use: sdk list java | grep -e installed -e local
This thread if full of workarounds but there's no doubt that some kind of a sdk list installed
command would be much more user friendly.
Point taken. I'll certainly include a flag listing only installed versions when I rewrite this command.
Guys, sdkman is awesome, it's insane that there isn't a simple in-framework way to say: "What are my installed java versions?" and "let me pick which one to make default" - simply.
@MTyson It's insanely simple!
$ sdk default java <tab>
Now pick the one you want to make default. As simple as you can get :smile:
That said, I'll still add the new flag mentioned above when this command is rewritten in Rust.
It works but it's workaround... Also I have some installs that have the label "local only", so I have to use:
sdk list java | grep -e installed -e local
This thread if full of workarounds but there's no doubt that some kind of asdk list installed
command would be much more user friendly.
This was the solution for me, just grep -e installed
did not contain all my local installed versions
Hi,
How to find what is installed with Sdkman?
There doesn't seem to be a
sdk list installed
commands, and just callingsdk list
simply shows all potential SDKs to install.Thanks.