asdf-vm/asdf

bug: getting "You have configured asdf to preserve downloaded files" when I don't

Mellbourn opened this issue · 6 comments

Describe the Bug

Every time I install a new version using asdf, I always get the warning "You have configured asdf to preserve downloaded files"
To start with I had no .asdfrc file, so that was strange.
Then I even created a .asdfrc file with an explicit setting always_keep_download = no but the warning persists.

Content of my $HOME/.asdfrc file:

legacy_version_file = yes
always_keep_download = no

Steps to Reproduce

  1. install something, e.g.
> asdf install direnv 2.31.0

Expected Behaviour

The following output only:

∗ Downloading and installing direnv...
The installation was successful!

Actual Behaviour

I always get two rows of warnings at the end of any installation:

∗ Downloading and installing direnv...
The installation was successful!
asdf: Warn: You have configured asdf to preserve downloaded files (with always_keep_download=yes or --keep-download). But
asdf: Warn: the current plugin (direnv) does not support that. Downloaded files will not be preserved.

Environment

OS:
Darwin Klass-MacBook-Pro-16-2023.local 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:55:06 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6020 arm64

SHELL:
zsh 5.9 (x86_64-apple-darwin23.0)

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=/Users/klas.mellbourn/.asdf
ASDF_DIR=/Users/klas.mellbourn/.asdf
ASDF_CONFIG_FILE=/Users/klas.mellbourn/.asdfrc

asdf plugins affected (if relevant)

ASDF INSTALLED PLUGINS:
bundler git@github.com:jonathanmorley/asdf-bundler.git master a461ac4
direnv git@github.com:asdf-community/asdf-direnv.git master a2219c2
java git@github.com:halcyon/asdf-java.git master fc28b48
lazydocker git@github.com:comdotlinux/asdf-lazydocker.git master abb6f71
nodejs git@github.com:asdf-vm/asdf-nodejs.git master c5b7c40
python git@github.com:danhper/asdf-python.git master 5e277e2
ruby git@github.com:asdf-vm/asdf-ruby.git master 7a22142

Warning was introduced in this commit but I guess condition is incorrect, it's triggered when both always_keep_download in .asdfrc isn't set to yes and --keep-download isn't provided, together with download directory missing.

I'm also facing this issue.
Interestingly if I set always_keep_download = yes it doesn't complain, so I think the flag check is botched and does the reverse of what it actually should.

I've also faced this issue after adding the zsh-adf-direnv plugin for zsh. It is the same message and it showed up the first time I ran terminal after installing it, but I've managed to install sqlite (which is what I wanted to install with asdf) through asdf without the message and it didn't show up the next times I opened terminal.

Environment:

OS: Pop!_OS 22.04 LTS x86_64 
Shell: zsh 5.8.1
BASH version: 5.1.16(1)-release
asdf version: v0.14.0-ccdd47d

@Mellbourn Hello there! 👋

I also have this issue, I am not using a .asdfrc but rather a .tool-versions and I am getting this warning on CI only, from the action asdf-vm/actions/install@v2. I guess it could be related.

Will the PR be merged "soon" ? 😅

I also experience this behaviour with asdf v0.14.0-ccdd47d.

Looking at the current code, it does indeed look like the test is "reversed", but in the sense that the existing test needed to be inverted (and the clauses rearranged) in 19515ed, but wasn't. Probably just a simple brain fart. 🙂

# 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

Basically, the current logic is "if not should-keep, (if exists, delete, else, warn)" but needs to be "if should-keep, (if not exists, warn), else (if exists, delete)". I just put together PR #1756, which should hopefully fix things.