Closed eprozium closed 3 years ago
sdk list java | grep -e installed -e local
is the actual answer. If you have a version that isn't available from sdkman anymore, it won't show up as installed. Instead it shows up as "Local Only"
That being said, it is both mind blowing and ridiculous that such a command still doesn't exist.
That being said, it is both mind blowing and ridiculous that such a command still doesn't exist
@heipl-paul this is a free and open source project run by volunteers. We spend our spare time delivering software that you get to use for free every day of your life. No cost and with no strings attached.
If a feature that you really want isn't supported, you can easily get stuck in and contribute by way of a pull request, provided that your code is up to standard. Alternatively, feel free to put down a bounty on our open collective page.
To see what versions are in use:
➜ ~ sdk current
Using:
gradle: 8.1.1
java: 17.0.7-tem
kotlin: 1.8.20
maven: 3.9.1
visualvm: 2.1.5
To list all available and installed versions of tools that at least have one version installed on the machine:
for i in `ls .sdkman/candidates/`; do sdk list $i; done
Haven't found out how to avoid the use of more
. The suggested grep doesn't work for the multi column syntax used for example for gradle.
Would be cool to have something like sdk list -h
/ sdk list --help
to get available flags listed.
agree with the sdk list --install stuff, would be more useful and intuitive IMHO. In addition, I have 4 JDK's installed and sometimes I have to use JDK11. Rather than grepping the internals of the sdkman what is the proper way to get folders for a sdk?
Hello, what's the progress? for list installed softwares.
Hello,
I have created an extension to do the trick. I added a file sdkman-installed.sh
in $SDKMAN_DIR/ext
with the following content:
#!/usr/bin/env bash
#stolen from src/main/bash/sdkman-list.sh!
function __sdkman_build_version_csv() {
local candidate versions_csv
candidate="$1"
versions_csv=""
if [[ -d "${SDKMAN_CANDIDATES_DIR}/${candidate}" ]]; then
for version in $(find "${SDKMAN_CANDIDATES_DIR}/${candidate}" -maxdepth 1 -mindepth 1 \( -type l -o -type d \) -exec basename '{}' \; | sort -r); do
if [[ "$version" != 'current' ]]; then
versions_csv="${version},${versions_csv}"
fi
done
versions_csv=${versions_csv%?}
fi
echo "$versions_csv"
}
function __sdkman_build_candidate_csv() {
local candidates_csv
candidates_csv=""
if [[ -d "${SDKMAN_CANDIDATES_DIR}" ]]; then
for candidate in $(find "${SDKMAN_CANDIDATES_DIR}" -maxdepth 1 -mindepth 1 -type d -exec basename '{}' \; | sort -r); do
candidates_csv="${candidate},${candidates_csv}"
done
candidates_csv=${candidates_csv%?}
fi
echo "$candidates_csv"
}
function __print_versions_installed() {
local versions_csv
versions_csv="$1"
local versions=($(echo ${versions_csv//,/ }))
for version in "${versions[@]}"; do
echo -e "\t* ${version}"
done
}
function __sdk_installed() {
local candidates_csv
candidates_csv=$(__sdkman_build_candidate_csv)
local candidates=($(echo ${candidates_csv//,/ }))
for candidate in "${candidates[@]}"; do
echo "* ${candidate}"
__print_versions_installed $(__sdkman_build_version_csv "${candidate}")
done
}
Now you can list installed candidates with sdk installed
.
The code is a little bit rough (there are duplicates...) but if there is interest I can clean it and make some tests to do a PR.
Pro tip: You can format the output with glow: sdk installed | glow -
.
Hi,
This is an old thread, not sure if in the meantime there is a better solution, but since sdk list will output the 'available' sdk's, when you're in online mode, it will show what is available online, while in offline mode, it shows what is available offline (thus installed).
The solution to your problem using the available commands of sdkman is thus (using example of java here) : prompt> sdk offline enable && sdk list java && sdk offline disable
@bvdriel i tried that, and it doesn't seem to work on MacOS. i have 11.0.20-tem and 17.0.8-tem installed and it only shows 11.0.20-tem
I tried something like this:
❯ ls ~/.sdkman/candidates/* | grep -v "current"
/Users/username/.sdkman/candidates/java:
11.0.16-ms
17.0.4.1-ms
17.0.8.1-ms
/Users/username/.sdkman/candidates/maven:
3.6.3
/Users/username/.sdkman/candidates/tomcat:
It's pretty similar to what mbogner has done in the previous thread.
@heipl-paul
sdk list java | grep -e installed -e local
is the actual answer. If you have a version that isn't available from sdkman anymore, it won't show up as installed. Instead it shows up as "Local Only"
This doesn't show my older hs-adpt
Java installs.
$ sdk use java
11.0.9.hs-adpt 13.0.2.hs-adpt 14.0.2.hs-adpt 15.0.1.hs-adpt 15.0.2.hs-adpt 16.0.1.hs-adpt 17.0.0-tem 19.0.2-tem 8.0.275.hs-adpt
$ sdk list java | grep -e installed -e local
We periodically need to update the local cache. Please run:
| | 19.0.2 | tem | local only | 19.0.2-tem
| >>> | 17.0.0 | tem | local only | 17.0.0-tem
Appreciate this is free, but it's still odd to make an SDK manager without a simple command to list your installed versions and which is currently selected. That would be like the first command I'd think of adding. Any other manager I've used has this feature e.g.
Node: nvm list
Ruby: rbenv versions
Python: pyenv versions
PHP: phpenv versions
Rust: rustup toolchain list
Go: gvm list
etc. But this is Java which exists in its own bubble of derangement like hermit hill troll that hasn't visited town for a few decades ;)
Could we maybe reopen this issue? — A lot of interest by the community …
Hi @sdavids,
did you see the comment with sdk current
? From my perspective this solves it for me. There you can see all installed packages (via sdkman) and the version. If you then want to drill down what versions exist for something you can do sdk list <name>
. So you have the overview and details call. A simple sdk list
gives you all available packages. What are you missing exactly?
sdk list
Using:
gradle: 8.7
java: 21.0.2-graalce
kotlin: 1.9.23
maven: 3.9.6
visualvm: 2.1.8
sdk list maven
================================================================================
Available Maven Versions
================================================================================
4.0.0-alpha-13 3.8.8 3.5.0
4.0.0-alpha-12 3.8.7 3.3.9
4.0.0-alpha-10 3.8.6 3.3.3
4.0.0-alpha-9 3.8.5 3.3.1
4.0.0-alpha-8 3.8.4 3.2.5
4.0.0-alpha-7 3.8.3 3.2.3
4.0.0-alpha-5 3.8.2 3.2.2
4.0.0-alpha-4 3.8.1 3.2.1
> * 3.9.6 3.6.3 3.1.1
3.9.5 3.6.2 3.1.0
3.9.4 3.6.1 3.0.5
3.9.3 3.6.0 3.0.4
3.9.2 3.5.4
3.9.1 3.5.3
3.9.0 3.5.2
================================================================================
+ - local version
* - installed
> - currently in use
================================================================================
sdk list
================================================================================
Available Candidates
================================================================================
q-quit /-search down
j-down ?-search up
k-up h-help
--------------------------------------------------------------------------------
Apache ActiveMQ (Classic) (5.17.1) https://activemq.apache.org/
Apache ActiveMQ® is a popular open source, multi-protocol, Java-based message
broker. It supports industry standard protocols so users get the benefits of
client choices across a broad range of languages and platforms. Connect from
clients written in JavaScript, C, C++, Python, .Net, and more. Integrate your
multi-platform applications using the ubiquitous AMQP protocol. Exchange
messages between your web applications using STOMP over websockets. Manage your
IoT devices using MQTT. Support your existing JMS infrastructure and beyond.
ActiveMQ offers the power and flexibility to support any messaging use-case.
$ sdk install activemq
--------------------------------------------------------------------------------
Ant (1.10.13) https://ant.apache.org/
Apache Ant is a Java library and command-line tool whose mission is to drive
processes described in build files as targets and extension points dependent
upon each other. The main known usage of Ant is the build of Java applications.
Ant supplies a number of built-in tasks allowing to compile, assemble, test and
run Java applications. Ant can also be used effectively to build non Java
applications, for instance C or C++ applications. More generally, Ant can be
used to pilot any type of process which can be described in terms of targets and
tasks.
$ sdk install ant
--------------------------------------------------------------------------------
AsciidoctorJ (2.5.12) http://asciidoctor.org/
AsciidoctorJ is the official library for running Asciidoctor on the JVM. Using
AsciidoctorJ, you can convert AsciiDoc content or analyze the structure of a
parsed AsciiDoc document from Java and other JVM languages.
$ sdk install asciidoctorj
--------------------------------------------------------------------------------
Ballerina (swan-lake-p3) https://ballerina.io/
Open source programming language and platform for cloud-era application
...
@mbogner
I would like to have something similar to
$ apt list --installed
list list [...] can display [...] installed (--installed) [...] versions.
https://manpages.ubuntu.com/manpages/xenial/man8/apt.8.html#description
or
$ dnf list --installed
dnf [options] list --installed [
...] Lists installed packages.
https://www.man7.org/linux/man-pages/man8/dnf.8.html
or
$ brew list
list
List all installed formulae.
https://docs.brew.sh/Manpage#list
$ sdk current
Using:
ant: 1.10.13
gradle: 8.7
java: 21.0.2-tem
maven: 3.9.6
$ sdk offline enable && sdk list java && sdk offline disable
Offline mode enabled.
--------------------------------------------------------------------------------
Offline: only showing installed java versions
--------------------------------------------------------------------------------
* 22-tem
> 21.0.2-tem
* 17.0.10-tem
* 11.0.22-tem
--------------------------------------------------------------------------------
* - installed
> - currently in use
--------------------------------------------------------------------------------
Online mode re-enabled!
$ sdk list java | grep -e installed -e local
| | 8.0.402 | librca | installed | 8.0.402-librca
Temurin | | 22 | tem | installed | 22-tem
| >>> | 21.0.2 | tem | installed | 21.0.2-tem
| | 17.0.10 | tem | installed | 17.0.10-tem
| | 11.0.22 | tem | installed | 11.0.22-tem
$ sdk installed java
================================================================================
Installed Java Versions
================================================================================
Vendor | Use | Version | Dist | Identifier
--------------------------------------------------------------------------------
Liberica | | 8.0.402 | librca | 8.0.402-librca
Temurin | | 22 | tem | 22-tem
| >>> | 21.0.2 | tem | 21.0.2-tem
| | 17.0.10 | tem | 17.0.10-tem
| | 11.0.22 | tem | 11.0.22-tem
$ sdk installed gradle
================================================================================
Installed Gradle Versions
================================================================================
> 8.7
8.6
7.4.1
Optional:
$ sdk installed
================================================================================
Installed Ant Versions
================================================================================
> 1.10.13
================================================================================
Installed Gradle Versions
================================================================================
> 8.7
8.6
7.4.1
================================================================================
Installed Java Versions
================================================================================
Vendor | Use | Version | Dist | Identifier
--------------------------------------------------------------------------------
Liberica | | 8.0.402 | librca | 8.0.402-librca
Temurin | | 22 | tem | 22-tem
| >>> | 21.0.2 | tem | 21.0.2-tem
| | 17.0.10 | tem | 17.0.10-tem
| | 11.0.22 | tem | 11.0.22-tem
================================================================================
Installed Maven Versions
================================================================================
> 3.9.6
or
$ sdk installed
================================================================================
Installed Versions
================================================================================
SDK | Vendor | Use | Version | Dist | Identifier
--------------------------------------------------------------------------------
Ant | | >>> | 1.10.13 | |
Gradle | | >>> | 8.7 | |
| | | 8.6 | |
| | | 7.4.1 | |
Java | Liberica | | 8.0.402 | librca | 8.0.402-librca
| Temurin | | 22 | tem | 22-tem
| | >>> | 21.0.2 | tem | 21.0.2-tem
| | | 17.0.10 | tem | 17.0.10-tem
| | | 11.0.22 | tem | 11.0.22-tem
Maven | | >>> | 3.9.6 | |
@sdavids Ok, got your point.
Isn't
apt list --installed
Listing... Done
adduser/jammy,now 3.118ubuntu5 all [installed,automatic]
amd64-microcode/jammy-updates,jammy-security,now 3.20191218.1ubuntu2.2 amd64 [installed,automatic]
apache2-bin/jammy-updates,now 2.4.52-1ubuntu4.8 amd64 [installed,automatic]
apache2-data/jammy-updates,now 2.4.52-1ubuntu4.8 all [installed,automatic]
apache2-utils/jammy-updates,now 2.4.52-1ubuntu4.8 amd64 [installed,automatic]
apache2/jammy-updates,now 2.4.52-1ubuntu4.8 amd64 [installed]
apparmor/jammy-updates,now 3.0.4-2ubuntu2.3 amd64 [installed,automatic]
apport-symptoms/jammy,now 0.24 all [installed,automatic]
apport/jammy-updates,now 2.20.11-0ubuntu82.5 all [installed,automatic]
apt-utils/jammy-updates,now 2.4.11 amd64 [installed,automatic]
apt/jammy-updates,now 2.4.11 amd64 [installed,automatic]
augeas-lenses/jammy,now 1.13.0-1 all [installed,automatic]
base-files/jammy-updates,now 12ubuntu4.6 amd64 [installed]
...
the same as
sdk current
?
Afaik you can't have multiple versions of the same debian package installed at the same time. That would be the selected one with sdkman. I agree that it would be nice for maintenance of a system to have a command that just lists all locally installed packages instead of just the currently selected version. Even more handy for me would be to have an option to uninstall all currently not used versions of all packages (or of listed packages). Something like this:
sdk uninstall java --keep-current
or for all installed packages ->
sdk uninstall --keep-current
I guess it is a question of how one defines "installed" …
a) "exists on the file system" b) "accessible via $PATH"
I'm using SDKMan to juggle between different major Java versions needed to build, test and benchmark different LTS branches of our software. The sdk installed
feature requested above by @sdavids sounds exactly like what I need.
I'm aware that sdk list java | egrep 'installed|local'
already does more or less what I want, but it's quite an awkward command to use.
why is closed?
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.