asdf-vm / asdf-vm/asdf

Add command line flag that prevents `asdf install` from ascending to parent directories

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

Description

### Is your feature request related to a problem? Please describe

I'm using asdf to install required tools in different projects (gradle/kts, vuejs, etc), and for those projects, I've added a hook before their respective build files kick in to effectively perform `asdf install` if `asdf` is found to be on the path. I noticed that `asdf install` ascends directories, installing everything found in `.tool-versions` files all the way up the tree. I want to tell `asdf install` to install only stuff that is specified in the current directory's `.tool-versions` file, and not to go up the directory tree, mostly because it's unnecessary and wastes time installing things that aren't relevant to the projects.

### Describe the proposed solution

Please add an option `--parent-recursion`, `--recursion`, or similar (you pick the name) that defaults to `-1`, meaning "go all the way up the directory tree" , preserving backward compatibility. However, when given `0`, this instructs asdf _not_ to ascend to parent directories, and any other positive number means "only go up this many parent directories".

Use cases:

* `asdf install --parent-recursion -1` is the same as `asdf install` and goes all the way up the tree.
* `asdf install --parent-recursion 0` causes no recursion up the directory tree, only installing what's in `./.tool-versions`.
* `asdf install --parent-recursion 1` causes `asdf install` to only install what's in `.tool-versions` in `.` & `..`.
* `asdf install --parent-recursion 2` causes `asdf install` to only install what's in `.tool-versions` in `.`, `..`, & `../..`.
* `asdf install --parent-recursion 1000000`, when run by an idiot where there are fewer than 100000 parent directories would be the same as `asdf install --parent-recursion -1`.

### Describe similar `asdf` features and why they are not sufficient

I'm not aware of any existing features similar to this.

### Describe other workarounds you've considered

I'm not aware of any possible workarounds for this.

Contributor guide

Open the contributing guide

Research direction

Start at the `asdf install` command entry point and trace how it discovers `.tool-versions` files in the current and parent directories. Review any existing command tests for recursive installation, then define coverage for the default behavior and parent-recursion values 0, 1, and larger limits; done means installation stops at the requested ancestor while preserving the default.

Written by the indexing model from the issue text.

Assessment

Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.