Closed jhcolville closed 1 year ago
Hi,
thanks very much for taking a look at this one so quickly, I looked forward to trying the fix.
Unfortunately the behaviour I'm seeing persists, e.g. here's a simple project folder with .terraform-version and .terragrunt-version, only .terragrunt-version is respected until I remove the terraform-ls plugin. I'm using rtx 1.32.1 with cleared cache and can see the file paths have changed, though that said it seems to me the plugin name was already incorporated into the path.
❯ rtx cache clear
rtx cache cleared
❯ rtx bin-paths
❯ cd project
❯ cat .terraform-version
0.12.24
❯ cat .terragrunt-version
0.37.3
❯ rtx bin-paths
/home/xxx/.local/share/rtx/installs/terragrunt/0.37.3/bin
❯ rtx plugin remove terraform-ls
rtx terraform-ls uninstalled ✓ 0s
❯ rtx bin-paths
[WARN] Tool not installed: terraform@0.12.24
/home/xxx/.local/share/rtx/installs/terragrunt/0.37.3/bin
❯ rtx install
...
rtx terraform@0.12.24 Extracting terraform archive ✓ 3s
❯ rtx bin-paths
/home/xxx/.local/share/rtx/installs/terragrunt/0.37.3/bin
/home/xxx/.local/share/rtx/installs/terraform/0.12.24/bin
❯ rtx doctor
rtx version:
1.32.1 linux-x64 (8ce9896 2023-06-27)
build:
Target: x86_64-unknown-linux-gnu
Features: SELF_UPDATE
Built: Tue, 27 Jun 2023 14:03:07 +0000
Rust Version: rustc 1.70.0 (90c541806 2023-05-31)
Profile: release
shell:
/bin/bash
GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
rtx environment variables:
RTX_SHELL=bash
settings:
{"experimental": "false", "missing_runtime_behavior": "warn", "always_keep_download": "false", "always_keep_install": "false", "legacy_version_file": "true", "plugin_autoupdate_last_check_duration": "10080", "trusted_config_paths": "[]", "verbose": "false", "asdf_compat": "false", "jobs": "4", "disable_default_shorthands": "false", "log_level": "INFO", "raw": "false"}
config files:
/home/xxx/.config/rtx/config.toml
/home/xxx/git/yyy/.terraform-version
/home/xxx/git/yyy/.terragrunt-version
plugins:
age https://github.com/threkk/asdf-age#4df80a0
argocd https://github.com/beardix/asdf-argocd.git#429bbf9
aws-vault https://github.com/karancode/asdf-aws-vault.git#678cacf
awscli https://github.com/MetricMike/asdf-awscli.git#2e31396
chezmoi https://github.com/joke/asdf-chezmoi.git#eefb05b
direnv https://github.com/asdf-community/asdf-direnv.git#7945cbb
fx https://gitlab.com/wt0f/asdf-fx.git#8ba1b03
fzf https://github.com/kompiro/asdf-fzf.git#d19eb67
go-getter https://github.com/ryodocx/asdf-go-getter.git#7483a12
helm https://github.com/Antiarchitect/asdf-helm.git#a39e17b
helmfile https://github.com/feniix/asdf-helmfile.git#3f1681e
iam-policy-json-to-terraform https://github.com/carlduevel/asdf-iam-policy-json-to-terraform.git#ac2b087
k9s https://github.com/looztra/asdf-k9s.git#2b3af87
kubectl https://github.com/asdf-community/asdf-kubectl.git#cbe6df4
kubectx https://gitlab.com/wt0f/asdf-kubectx.git#8c0b4aa
kubent https://github.com/virtualstaticvoid/asdf-kubent.git#7a1d974
kubeval https://github.com/stefansedich/asdf-kubeval.git#6ccc18f
kustomize https://github.com/Banno/asdf-kustomize.git#2efaa38
node (core)
packer https://github.com/asdf-community/asdf-hashicorp.git#c44c314
python (core)
ripgrep https://gitlab.com/wt0f/asdf-ripgrep.git#e836665
shellcheck https://github.com/luizm/asdf-shellcheck.git#b160a52
shfmt https://github.com/luizm/asdf-shfmt.git#a42c5ff
sops https://github.com/feniix/asdf-sops.git#954411c
starship https://github.com/grimoh/asdf-starship.git#f546452
stern https://github.com/looztra/asdf-stern.git#e17efba
task https://github.com/particledecay/asdf-task.git#54ee5e6
terraform https://github.com/asdf-community/asdf-hashicorp.git#c44c314
terraform-docs https://github.com/looztra/asdf-terraform-docs.git#3ec72e5
terragrunt https://github.com/ohmer/asdf-terragrunt.git#4a6651a
yq https://github.com/sudermanjr/asdf-yq.git#772992f
toolset:
terragrunt@0.37.3, terraform@0.12.24
No problems found
❯ ls -la ~/.cache/rtx/*/legacy/*/*
-rw-r--r--. 1 xxx domain users 7 Jun 28 14:10 /home/xxx/.cache/rtx/terraform/legacy/terraform/c0b89868100570d9.txt
-rw-r--r--. 1 xxx domain users 0 Jun 28 14:09 /home/xxx/.cache/rtx/terraform-ls/legacy/terraform-ls/c0b89868100570d9.txt
-rw-r--r--. 1 xxx domain users 6 Jun 28 14:10 /home/xxx/.cache/rtx/terragrunt/legacy/terragrunt/9a4d5188f8450664.txt
It seemed to me anyway that the cache files were already separated by plugin name, but when multiple plugins had the same source the cache files would always be zero size and they'd all be dropped into the directory indicated by the alphabetically last plugin name. Sorry if I'm not making this very clear, but here's another example where I incrementally remove plugins and you can see the cache directories being correctly populated as a result:
❯ rtx cache clear
rtx cache cleared
~/git
❯ ls -la ~/.cache/rtx/*/legacy/*/*
ls: cannot access '/home/xxx/.cache/rtx/*/legacy/*/*': No such file or directory
❯ cd project
❯ ls -la ~/.cache/rtx/*/legacy/*/*
-rw-r--r--. 1 xxx domain users 0 Jun 28 14:34 /home/xxx/.cache/rtx/terraform-ls/legacy/terraform-ls/b1da58780313d359.txt
-rw-r--r--. 1 xxx domain users 0 Jun 28 14:34 /home/xxx/.cache/rtx/terraform-ls/legacy/terraform-ls/c0b89868100570d9.txt
❯ rtx bin-paths
❯ rtx plugin remove terraform-ls
rtx terraform-ls uninstalled ✓ 0s
❯ ls -la ~/.cache/rtx/*/legacy/*/*
-rw-r--r--. 1 xxx domain users 0 Jun 28 14:35 /home/xxx/.cache/rtx/terraform/legacy/terraform/b1da58780313d359.txt
-rw-r--r--. 1 xxx domain users 7 Jun 28 14:35 /home/xxx/.cache/rtx/terraform/legacy/terraform/c0b89868100570d9.txt
-rw-r--r--. 1 xxx domain users 0 Jun 28 14:34 /home/xxx/.cache/rtx/terraform-ls/legacy/terraform-ls/b1da58780313d359.txt
-rw-r--r--. 1 xxx domain users 0 Jun 28 14:34 /home/xxx/.cache/rtx/terraform-ls/legacy/terraform-ls/c0b89868100570d9.txt
❯ rtx bin-paths
[WARN] Tool not installed: terraform@0.12.24
❯ rtx plugin remove terraform
rtx terraform uninstalled ✓ 0s
❯ ls -la ~/.cache/rtx/*/legacy/*/*
-rw-r--r--. 1 xxx domain users 5 Jun 28 14:35 /home/xxx/.cache/rtx/packer/legacy/packer/b1da58780313d359.txt
-rw-r--r--. 1 xxx domain users 0 Jun 28 14:35 /home/xxx/.cache/rtx/packer/legacy/packer/c0b89868100570d9.txt
-rw-r--r--. 1 xxx domain users 0 Jun 28 14:35 /home/xxx/.cache/rtx/terraform/legacy/terraform/b1da58780313d359.txt
-rw-r--r--. 1 xxx domain users 7 Jun 28 14:35 /home/xxx/.cache/rtx/terraform/legacy/terraform/c0b89868100570d9.txt
-rw-r--r--. 1 xxx domain users 0 Jun 28 14:34 /home/xxx/.cache/rtx/terraform-ls/legacy/terraform-ls/b1da58780313d359.txt
-rw-r--r--. 1 xxx domain users 0 Jun 28 14:34 /home/xxx/.cache/rtx/terraform-ls/legacy/terraform-ls/c0b89868100570d9.txt
❯ rtx bin-paths
/home/xxx/.local/share/rtx/installs/packer/1.8.6/bin
If there's anything more I can do to illustrate let me know, I'll have a dig through the source but rust is far from my strongest suit.
Thanks again,
Johan
ah yeah I see and I can repro. Once you add terraform-ls it breaks the config parsing for terraform. There is an assumption in the data model that each legacy file only has a single tool associated with it: https://github.com/jdxcode/rtx/blob/7d4ed3979dab1a6e681280304847764f4acfeb1a/src/config/mod.rs#L338
I think that might need to be modified to be a list, but that's easier said than done since it requires a fair bit of changes to other code.
Describe the bug
Hi, first thanks very much to all the contributors to this project, I think it's a great tool. I'm not 100% sure this is a bug, but the behaviour I'm seeing is that if I have multiple plugins installed using the same source (e.g. terraform-ls, terraform, packer - all sharing the asdf-hashicorp.git source) and I try to use legacy version files in a project (e.g. .terraform-version, .packer-version) rtx does not attempt to manage the version specified in those files. The behaviour seems to be that the version to use is cached as an empty file in the cache legacy folder of the lexicographically last plugin name.
By removing the order-last plugin one at a time the prior plugin's .tool-version begins to work, e.g. removing the terraform-ls plugin enables the .terraform-version to be correctly parsed and managed.
To Reproduce
Expected behavior
rtx should make the tool version matching the specification in the legacy version file available
rtx doctor
outputI hope I've provided enough detail, if there's anything more I can do to help illustrate the problem please let me know.
Using .tool-versions file, or .toml, or RTX_PLUGIN_VERSION environment variables all works fine and I'd just do that except that I'm trying to migrate a team of engineers and a lot of repositories over to rtx to replace a lot of piecemeal environment manager scripts and it would be ideal if rtx could be a drop-in replacement.
Thanks,
Johan