Skip to content

fix(detector): align asdf env var on ASDF_DATA_DIR across detector, classifier, docs#84

Merged
dipto0321 merged 1 commit into
mainfrom
fix/detector/asdf-env-var
Jul 3, 2026
Merged

fix(detector): align asdf env var on ASDF_DATA_DIR across detector, classifier, docs#84
dipto0321 merged 1 commit into
mainfrom
fix/detector/asdf-env-var

Conversation

@dipto0321

Copy link
Copy Markdown
Owner

Summary

The asdf branch of internal/detector/system_node.go's managerManagedRoots was reading $ASDF_DIR to discover the manager's data dir, while internal/detector/asdf.go::asdfDataDir() (the function the detector's actual Install/ListInstalled paths shell out against) reads $ASDF_DATA_DIR — and docs/managers.md documented $ASDF_DIR in the supported-manager table. The three were inconsistent.

A user with ASDF_DIR=/path/to/asdf-source (the source checkout from a git-clone install) would have nodeup classify the node binary under that source dir as manager-managed even though the manager's actual install location was elsewhere (typically ~/.asdf). Conversely, a user with the canonical ASDF_DATA_DIR override would have it silently ignored by the path classifier, leaving their manager install to be reported as unknown in nodeup check and triggering the upgrade-time warning.

Unify all three on $ASDF_DATA_DIR, matching the variable asdfDataDir() already used and the official asdf docs (the source-checkout variable is $ASDF_DIR; the data-dir override is $ASDF_DATA_DIR). Update system_node_test.go's "asdf env wins" case to drive the new variable, and detector.go's package doc comment to match.

Closes #50.

Linked issues

Type of change

  • fix — bug fix (PATCH bump)

Checklist

  • Title follows Conventional Commits (fix(scope): subject)
  • I ran make ci locally and it passes (fmt, vet, test pass locally; make lint fails on the v2→v1 schema mismatch tracked in build(lint): .golangci.yml v1 schema incompatible with golangci-lint v2 (brew installs v2, make lint fails to even parse config) #62 — pre-existing on main, independent of this fix; CI runs golangci-lint v1.64.8 per .github/workflows/ci.yml and parses the config fine)
  • I added or updated tests for the change (updated system_node_test.go's "asdf env wins" case to use ASDF_DATA_DIR instead of ASDF_DIR; existing asdf_test.go::TestASDF_Detect_HonorsASDF_DATA_DIR and the ASDF_DATA_DIR data-dir resolution tests already cover the rest of the contract)
  • I updated relevant docs (README, docs/, inline godoc)
  • No new linter warnings
  • If breaking: I documented the migration path in the PR body and updated CHANGELOG.md (N/A — no user-visible flag changes; only a previously-ignored env var now works and a previously-honored env var on the wrong directory is no longer honored)

Scope notes

  • internal/detector/detector.go had a package-doc comment listing the supported env vars including ASDF_DIR. Updated to ASDF_DATA_DIR.
  • The asdf-asdf inconsistency is purely a "wrong env var name" bug, not a parsing or matching issue. Single-token replacement in each of three places.
  • I deliberately did NOT support $ASDF_DIR as an additional fallback (some installations use it as an alias for the data dir). The official asdf docs distinguish the two cleanly: $ASDF_DIR is the source checkout, $ASDF_DATA_DIR is the data dir. If a user is using $ASDF_DIR to mean "data dir" they should switch to $ASDF_DATA_DIR — the same variable the rest of their tooling already uses.
  • The fix is intentionally scoped to the asdf path on its own; no other manager has this dual-env-var confusion in the codebase.

Out of scope (separate issues)

Screenshots / output

User-visible behavior change:

  • Before: User with ASDF_DIR=/path/to/source set in their env (typical for git-clone installs) sees nodeup check print a warning that their node binary isn't manager-managed even though asdf fully owns it. Conversely, a user with ASDF_DATA_DIR=/custom sees the classifier claim their node is "manager" only when it happens to land under ~/.asdf (the fallback path).
  • After: ASDF_DATA_DIR is the single source of truth: setting it points the classifier at the actual data dir, regardless of what $ASDF_DIR happens to contain.

Verification path: go test -race ./internal/detector/... -run TestSystemNode_ManagerManagedRoots -v (the test table now exercises ASDF_DATA_DIR directly).

…lassifier, docs

The asdf branch of `managerManagedRoots` (system_node.go) was
reading `$ASDF_DIR` to discover the manager's data dir, while
`asdfDataDir()` (the function the detector's actual
`Install`/`ListInstalled` paths shell out against) reads
`$ASDF_DATA_DIR` — and `docs/managers.md` documented `$ASDF_DIR`
in the supported-manager table. The three were inconsistent.

A user with `ASDF_DIR=/path/to/asdf-source` (the source checkout
from a git-clone install) would have nodeup classify the `node`
binary under that source dir as `manager`-managed even though the
manager's actual install location was elsewhere (typically
`~/.asdf`). Conversely, a user with the canonical `ASDF_DATA_DIR`
override would have it silently ignored by the path classifier,
leaving their manager install to be reported as `unknown` in
`nodeup check` and triggering the upgrade-time warning.

Unify all three on `$ASDF_DATA_DIR`, matching the variable
`asdfDataDir()` already used and the official asdf docs (the
source-checkout variable is `$ASDF_DIR`; the data dir override
is `$ASDF_DATA_DIR`). Update the `system_node_test.go` "asdf env
wins" case to drive the new variable, and `detector.go`'s
package doc comment to match.

Closes #50.

Co-Authored-By: puku-ai-2.8 <noreply@puku.sh>
@cocogitto-bot

cocogitto-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

✔️ 9707118 - Conventional commits check succeeded.

@dipto0321 dipto0321 merged commit a0a6bcd into main Jul 3, 2026
10 checks passed
@dipto0321 dipto0321 deleted the fix/detector/asdf-env-var branch July 3, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(detector): asdf uses ASDF_DIR vs ASDF_DATA_DIR inconsistently between docs, detector, and system-node classifier

1 participant