asdf-vm/asdf

bug: always_keep_download has a wrong warning logic

Closed this issue · 2 comments

Describe the Bug

A warn is show stating that you have set the option always_keep_download to yes or used the option --keep-download while neither of those where set.
The bug is in file lib/functions/installs.bash at line 239

Steps to Reproduce

  1. Clone the asdf-vm repo
  2. Use default settings or explicit set always_keep_download to no in asdfrc
  3. Add a plugin that doesn't support keep_downloads, for example deno
  4. Try to install any version of deno runtime
  5. See the warning message

Expected Behaviour

The warning message shouldn't be trigger

Actual Behaviour

A warning message for unsupported option always_keep_download in plugin is triggered

Environment

OS:
Linux moonchild 6.8.9-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 02 May 2024 17:49:46 +0000 x86_64 GNU/Linux

SHELL:
zsh 5.9 (x86_64-pc-linux-gnu)

BASH VERSION:
5.2.26(1)-release

ASDF VERSION:
v0.14.0-ccdd47d

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/home/moon/.asdf
ASDF_DIR=/home/moon/.asdf
ASDF_CONFIG_FILE=/home/moon/.config/.asdfrc

ASDF INSTALLED PLUGINS:
deno                         https://github.com/asdf-community/asdf-deno.git master fec2a08

asdf plugins affected (if relevant)

No response

lines: 237 up to 246 in file lib/functions/installs.bash

....
# Remove download directory if --keep-download flag or always_keep_download config setting are not set
      always_keep_download=$(get_asdf_config_value "always_keep_download")
      if [ ! "$keep_download" = "true" ] && [ ! "$always_keep_download" = "yes" ]; then
        if [ -d "$download_path" ]; then
          rm -r "$download_path"
        else
          printf '%s\n' "asdf: Warn: You have configured asdf to preserve downloaded files (with always_keep_download=yes or --keep-download). But" >&2
          printf '%s\n' "asdf: Warn: the current plugin ($plugin_name) does not support that. Downloaded files will not be preserved." >&2
        fi
      fi
...

It's checking if keep_downloadis not equal to truenor yes and tries to remove the directory, however if the directory does not exist it shows the warning, the warning should be behind a check to see if the option is set

Oh sorry, duplicate of #1711 . Closing it