asdf-vm / asdf-vm/asdf

Allow running tools from one another without passing `ASDF_DATA_DIR` around

Open
#1,716 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` for most of my development work.

I'm currently working on a job where test runners spawn each other.
Our `nodejs` test runner starts up a `java` server for example,
with an empty env, except for `PATH`.

I've got all tools set up in `.tool-versions`.

When calling `java` from `nodejs` the error is:
```
unknown command: java. Perhaps you have to reshim?
```

This can be fixed by adding `ASDF_DATA_DIR` to the env in the `nodejs` code that
spawns `java`.

Is there a way of avoiding this, I don't want to force my package manager on the project.

I've set up a reproduction repo [here](https://github.com/romeovs/asdf-test).

### Describe the proposed solution

Could the shims for the all current `.tool-version` be references in the `PATH` variable set when called a tool is called?

For example: in the [reproduction repo I set up](https://github.com/romeovs/asdf-test), `golang` gets the following items in it's `PATH` (that are not coming from my shell environment):
```
/Users/romeo/.asdf/installs/golang/1.21.6/go/bin
/Users/romeo/.asdf/installs/golang/1.21.6/packages/bin
```
Could this also include the node installs?

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

None come to mind.

### Describe other workarounds you've considered

Adding the `ASDF_DATA_DIR` environment variable to the spawn call works, but forces the code to know about `asdf` which I would like to avoid.

Contributor guide

Open the contributing guide

Research direction

Reproduce the empty-environment tool spawn from the linked asdf-test repository, then inspect the shim and PATH behavior described in the issue. Done means tools selected by .tool-versions can launch one another without passing ASDF_DATA_DIR into the child environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, java, node.js
Domain
cli, developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.