asdf-vm / asdf-vm/asdf

bug: -p / --parent should also operate in the current directory

Open
#2,224 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

This is tangentially related to #2221.

It would be helpful if `-p` / `--parent` would also find the .tool-versions in the current working directory. That would mean that one can almost always rely on asdf with `-p` changing the local tool version.

It looks like this would be achieved simply by *not* setting `directory = filepath.Dir(directory)` before the loop in internal/cli/set/set.go `findVersionFileInParentDir`.

Also, I'm not seeing the stderr message that the source suggests I should see when a parent .tool-versions isn't found. If I redirect stderr to file, there's nothing in the file, either.

### Steps to Reproduce

1. cd $SOME_ASDF_PROJECT_DIR
2. `cat .tool-versions`
3. `asdf set -p $SOME_TOOL $SOME_VERSION`
4. `cat .tool-versions`

### Expected Behaviour

With the source as it currently is, I would expect to see a message on stderr from the `asdf set`, and `.tool-versions` to remain unchanged.

With my requested change so that `-p` also operates on `.tool-versions` in the current directory, I wouldn't expect anything on stderr, but the `.tool-versions` to be updated.

### Actual Behaviour

I'm not seeing anything on stderr from the `asdf set`, but nor am I seeing any change to the contents of .tool-versions.

### Environment

```shell
OS:
Darwin NSWMBP.powerhub 24.6.0 Darwin Kernel Version 24.6.0: Wed Oct 15 21:12:06 PDT 2025; root:xnu-11417.140.69.703.14~1/RELEASE_ARM64_T6000 arm64

SHELL:
zsh 5.9 (arm64-apple-darwin24.0)

BASH VERSION:
5.3.9(1)-release

ASDF VERSION:
0.18.0 (revision unknown)

ASDF INTERNAL VARIABLES:
ASDF_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/neil/.asdf
ASDF_CONFIG_FILE=/Users/neil/.asdfrc

ASDF INSTALLED PLUGINS:
dart https://github.com/PatOConnor43/asdf-dart.git
d14ad3bd609d6c3115863f1cc69510b39d9adbc0
dotnet-core https://github.com/emersonsoares/asdf-dotnet-core.git
4583e4b87b48d39e37ed0acbf54481297d6b4992
flutter https://github.com/oae/asdf-flutter.git
7212108e5f89f1e424d65bd86b5995985fc272bf
golang https://github.com/asdf-community/asdf-golang.git
50c8f58237da34223d31ac9e62e5d5f8dcc13f5f
haskell https://github.com/asdf-community/asdf-haskell.git
cabd4cd8ad99b717dacce8f26c8cc7de3546b373
java https://github.com/halcyon/asdf-java.git
774735dd7a4c1e4577572803d1bb239d08da04d8
nodejs https://github.com/asdf-vm/asdf-nodejs.git
90b8ecaa556916daba983a7b01869a9ea682f285
php https://github.com/asdf-community/asdf-php.git
7a9a0c1fa7a659f3e317ee84e30f7c9ba5dc8022
ruby https://github.com/asdf-vm/asdf-ruby.git
26be0ebf43b47dba9bf244995700deeaa572b281

(asdf was installed with homebrew)
```

### asdf plugins affected (if relevant)

N/A

Contributor guide

Open the contributing guide

Research direction

Start in internal/cli/set/set.go at findVersionFileInParentDir and inspect the existing set command tests for parent-directory behavior. Verify the current directory is checked first, confirm the .tool-versions file is updated by `asdf set -p`, and investigate the expected stderr behavior in the same path.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.