should skip downloading if the file exists and checksum is correct
hi, i used to be a asdf user, now i switched to rtx, it's really great.
[root@VM-16-11-centos ~]# cp /tmp/OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz /root/.local/share/rtx/downloads/java/temurin-8.0.372+7/
[root@VM-16-11-centos ~]# sha256sum /root/.local/share/rtx/downloads/java/temurin-8.0.372+7/OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz
78a0b3547d6f3d46227f2ad8c774248425f20f1cd63f399b713f0cdde2cc376c /root/.local/share/rtx/downloads/java/temurin-8.0.372+7/OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz
[root@VM-16-11-centos ~]# RTX_TRACE=1 rtx install [email protected]+7
[TRACE] (1) rtx::config: [src/config/mod.rs:281] settings does not exist "/root/.config/rtx/config.toml"
[TRACE] (1) rtx::plugins::rtx_plugin_toml: [src/plugins/rtx_plugin_toml.rs:29] parsing: /root/.local/share/rtx/plugins/python/rtx.plugin.toml
[TRACE] (1) rtx::plugins::rtx_plugin_toml: [src/plugins/rtx_plugin_toml.rs:29] parsing: /root/.local/share/rtx/plugins/java/rtx.plugin.toml
[TRACE] (1) rtx::config::config_file::tool_versions: [src/config/config_file/tool_versions.rs:56] parsing tool-versions: /root/.tool-versions
[TRACE] (1) rtx::config: [src/config/mod.rs:70] Settings: Settings {
experimental: false,
missing_runtime_behavior: Warn,
always_keep_download: false,
always_keep_install: false,
legacy_version_file: true,
plugin_autoupdate_last_check_duration: 604800s,
trusted_config_paths: [],
verbose: true,
asdf_compat: false,
jobs: 4,
shorthands_file: None,
disable_default_shorthands: false,
log_level: Trace,
raw: false,
}
[TRACE] (7) rtx::cache: [src/cache.rs:78] reading ~/.cache/rtx/golang/legacy_filenames.msgpack.z
[TRACE] (6) rtx::cache: [src/cache.rs:78] reading ~/.cache/rtx/elixir/legacy_filenames.msgpack.z
[DEBUG] Files: ~/.tool-versions
Installed Plugins: ag, elixir, erlang, fd, fzf, golang, java, maven, python, tmux, zoxide
[DEBUG] rtx install [email protected]+7
[TRACE] (3) rtx::cache: [src/cache.rs:78] reading ~/.cache/rtx/java/aliases.msgpack.z
[TRACE] (5) rtx::cache: [src/cache.rs:78] reading ~/.cache/rtx/python/remote_versions.msgpack.z
[DEBUG] java@oracle-17, [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
[TRACE] (14) rtx::cache: [src/cache.rs:78] reading ~/.cache/rtx/java/remote_versions.msgpack.z
[TRACE] (14) rtx::file: [src/file.rs:37] mkdir -p /root/.cache/rtx/lockfiles
[TRACE] (14) rtx::file: [src/file.rs:20] rm -rf /root/.local/share/rtx/installs/java/temurin-8.0.372+7
[TRACE] (14) rtx::file: [src/file.rs:20] rm -rf /root/.local/share/rtx/downloads/java/temurin-8.0.372+7
[TRACE] (14) rtx::file: [src/file.rs:20] rm -rf /root/.cache/rtx/java/temurin-8.0.372+7
[TRACE] (14) rtx::file: [src/file.rs:37] mkdir -p /root/.local/share/rtx/installs/java/temurin-8.0.372+7
[TRACE] (14) rtx::file: [src/file.rs:37] mkdir -p /root/.local/share/rtx/downloads/java/temurin-8.0.372+7
[TRACE] (14) rtx::file: [src/file.rs:37] mkdir -p /root/.cache/rtx/java/temurin-8.0.372+7
installing
[DEBUG] $ /root/.local/share/rtx/plugins/java/bin/install
++ uname -s
+ KERNEL_NAME=Linux
+ case "${KERNEL_NAME}" in
+ OS=linux
+ SHA256SUM=sha256sum
+ STAT=stat
+ STAT_OPTS=('-c' '%Z')
++ uname -m
+ MACHINE=x86_64
+ case "${MACHINE}" in
+ ARCHITECTURE=x86_64
+ case "$(basename "${0}")" in
++ basename /root/.local/share/rtx/plugins/java/bin/install
+ install
+ local release_data package_link package_filename checksum
+ local -a dirs
+ retrieve-release-data
+ local cache_file=/root/.cache/rtx/java/releases-linux-x86_64.tsv
+ [[ ! -r /root/.cache/rtx/java/releases-linux-x86_64.tsv ]]
++ stat -c %Z /root/.cache/rtx/java/releases-linux-x86_64.tsv
++ date +%s
+ (( 1685839191 <= 1685839540 - 3600 ))
+ [[ temurin-8.0.372+7 =~ ^[0-9] ]]
++ grep '^temurin-8.0.372+7 ' /root/.cache/rtx/java/releases-linux-x86_64.tsv
++ tail -n 1
+ release_data='temurin-8.0.372+7 OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u372-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz 78a0b3547d6f3d46227f2ad8c774248425f20f1cd63f399b713f0cdde2cc376c'
+ [[ -z temurin-8.0.372+7 OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u372-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz 78a0b3547d6f3d46227f2ad8c774248425f20f1cd63f399b713f0cdde2cc376c ]]
++ cut -d ' ' -f 2
+ package_filename=OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz
++ cut -d ' ' -f 3
+ package_link=https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u372-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz
++ cut -d ' ' -f 4
+ checksum=78a0b3547d6f3d46227f2ad8c774248425f20f1cd63f399b713f0cdde2cc376c
+ [[ OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz =~ zip\$ ]]
+ cd /root/.local/share/rtx/downloads/java/temurin-8.0.372+7
+ curl -LO -# -w 'OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz\n' https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u372-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz
[root@VM-16-11-centos ~]# rtx version
1.32.0 linux-x64 (da025fe 2023-06-03)
in China, download from Github releases is not always reliable, for python or nodejs installation. we can set mirrors. for rtx-plugins/rtx-golang, i've sent a pr.
export PYTHON_BUILD_MIRROR_URL_SKIP_CHECKSUM=false
export PYTHON_BUILD_MIRROR_URL=https://repo.huaweicloud.com/python/
export NODE_BUILD_MIRROR_URL=https://npmmirror.com/mirrors/node/
export GOLANG_DOWNLOAD_MIRROR=https://mirrors.aliyun.com/golang
but for java installation, it seems there is no MIRROR env support. i think for a better installation experience, it's better to have BUILD_MIRROR_URL or DOWNLOAD_MIRROR_URL support. but if unavailable. at least output log like rtx-java plugin
+ checksum=78a0b3547d6f3d46227f2ad8c774248425f20f1cd63f399b713f0cdde2cc376c
+ [[ OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz =~ zip\$ ]]
+ cd /root/.local/share/rtx/downloads/java/temurin-8.0.372+7
+ curl -LO -# -w 'OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz\n' https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u372-b07/OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz
and skip download if file exist in the right directory and checksum is correct.
sorry i'm not a rust user, i can only suggest.
by the way, for asdf, if you extract the zip to ~/.asdf/installs/, asdf ls can manage it. but rtx won't. why ?
$ tar xvf /tmp/OpenJDK8U-jdk_x64_linux_hotspot_8u372b07.tar.gz --strip-components=1 -C /root/.local/share/rtx/installs/java/temurin-8.0.372+7/
$ ls /root/.local/share/rtx/installs/java/temurin-8.0.372+7/
$ rtx ls java
java oracle-17 ~/.tool-versions oracle-17
java 17
@dfang Extracting the .tar.gz to ~/.local/share/rtx/installs/java/termurin8u372b07 should work fine. If rtx ls does not show the runtime, try clearing the cache via rtx cache clear.