asdf-vm / asdf-vm/asdf

bug: asdf fails to list or install plugins when executed inside a non-existent working directory

Open
#2,135 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
25.6k
Forks
941
Avg merge
9h 24m
Merged PRs (30d)
3

Description

### Describe the Bug

When executing some asdf commands in a terminal where PWD is set to a non-existent directory, the command fails and exits 1 with an internal log (e.g. - from `git` or `os.getwd`).

### Steps to Reproduce

```shell
> mkdir test && cd test
> rmdir ${PWD}
> asdf list
x unable to get current directory: getwd: no such file or directory
> asdf plugin list all | grep flyctl
flyctl https://github.com/chessmango/asdf-flyctl.git
> asdf plugin add flyctl
x unable to clone plugin: fatal: fetch-pack: invalid index-pack output
```

### Expected Behaviour

I assume the `getwd` failure is from checking if there is a `.tool-versions` in the current directory or any parent directories to put a `*` on the version that would be in use from that terminal. I believe it would make sense to fix this by ignoring the `getwd` failure and moving up the directory tree as normal.

The clone error is a git error, and I'm not sure there is a good way to fix it from inside asdf, since even basic git commands like `git clone https://github.com/chessmango/asdf-flyctl.git ~/.asdf/plugins/flyctl` fails under this condition. This whole ticket can probably just be closed as WONTFIX, but I wanted to have it available and searchable for anyone else encountering this problem in the future.

### Actual Behaviour

the command fails and exits 1

### Environment

```shell
OS:
Linux User 6.14.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 09 May 2025 17:36:18 +0000 x86_64 GNU/Linux

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

BASH VERSION:
5.2.37(1)-release

ASDF VERSION:
0.17.0-arch (revision d536803)

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

ASDF INSTALLED PLUGINS:
aws-iam-authenticator ssh://git@github.com/zekker6/asdf-aws-iam-authenticator
fd1866a32dabc47118d866b7cf8d32dcb4aa3ce3
crossplane-cli ssh://git@github.com/joke/asdf-crossplane-cli.git
dd2a2a62bb049806ad13b514df7563718272d962
cue ssh://git@github.com/asdf-community/asdf-cue.git
32d1e0181755eb1dcb268c2cf30087833e2887a4
flux2 ssh://git@github.com/tablexi/asdf-flux2.git
771755e66120e95626ec798d26bcd473aca93795
flyctl ssh://git@github.com/chessmango/asdf-flyctl.git
e87344f9b9e574dc8372859dfa098aadd8df81d8
golang ssh://git@github.com/asdf-community/asdf-golang.git
e2527a31714da7bc671a684308579f4ef8863281
helm ssh://git@github.com/Antiarchitect/asdf-helm.git
085651c91e61936289ed79976fe3ba53bf6787ae
just ssh://git@github.com/olofvndrhr/asdf-just.git
3f907ee4ca331e5caf9768b33137fcf9f752f8f1
kind ssh://git@github.com/johnlayton/asdf-kind.git
1201d8c348952291a2f661016e3e7085d301631e
kops ssh://git@github.com/Antiarchitect/asdf-kops.git
1b00fe1b4b55f662c6382b2e4a143feb32397743
kubectl ssh://git@github.com/asdf-community/asdf-kubectl.git
2fb3b57090e3efe55953a751a134c271ba83b119
kustomize ssh://git@github.com/Banno/asdf-kustomize.git
8e929af8d10e589e0e5ac993b3521a1644bbafde
marp-cli ssh://git@github.com/xataz/asdf-marp-cli
18eaf742b877b4110b514a8de6186d8dc0f8163a
mysql ssh://git@github.com/iroddis/asdf-mysql.git
8031228971ee42f96ca4cd0d9250e76424691858
opentofu ssh://git@github.com/virtualroot/asdf-opentofu.git
f9f626482b8f4a7a423d584823c41b9b26bc5c3a
postgres ssh://git@github.com/smashedtoatoms/asdf-postgres.git
acbbc49a78c40225a7ae8fe1eb14ce9ff96c64ce
python ssh://git@github.com/danhper/asdf-python.git
a3a01856098d6d2b9642e382f5b38e70275726d1
terraform ssh://git@github.com/asdf-community/asdf-hashicorp.git
22eb1c4a16adcde39aaaf89fbb5d9404a1601fce
terragrunt ssh://git@github.com/ohmer/asdf-terragrunt.git
29f29350c45f6e71b7acf68ec202586ccd2cf7af
uv ssh://git@github.com/asdf-community/asdf-uv.git
ce093c3592cee00029413c75c896d7c29e1bd51a
yarn ssh://git@github.com/twuni/asdf-yarn.git
376c5407ef22c82fa56e4bd9f6a9108354063acb
```

### asdf plugins affected (if relevant)

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure by removing the current directory, then run the reported `asdf list`, `asdf plugin list all`, and `asdf plugin add flyctl` commands. Trace the current-directory lookup used by these CLI entry points and compare it with the Git clone failure. Done means affected commands no longer exit unexpectedly where asdf can handle the missing working directory, with the Git limitation documented or confirmed.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, go, shell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.