Skip to content

Fix auto-venv compatibility with nushell 0.108#1252

Open
hyiltiz wants to merge 1 commit intonushell:mainfrom
hyiltiz:fix/auto-venv-0.108-compat
Open

Fix auto-venv compatibility with nushell 0.108#1252
hyiltiz wants to merge 1 commit intonushell:mainfrom
hyiltiz:fix/auto-venv-0.108-compat

Conversation

@hyiltiz
Copy link
Copy Markdown
Contributor

@hyiltiz hyiltiz commented May 8, 2026

Summary

auto-venv is broken on nushell 0.108 due to several API changes in the
engine. This PR fixes all the issues needed to make it functional again.

Fixes:

  • default-hooks wrapped the existing PWD hooks list in another list,
    producing an invalid list<list<closure>> type that corrupted hook
    evaluation (and broke tab completion as a side effect)

  • on_enter used transient cd to resolve overlay use relative to
    PWD; nushell 0.108 resolves overlay use at parse time only, so
    this no longer works — removed in favor of NU_LIB_DIRS resolution

  • on_exit crashed when the overlay was not active (e.g. activation
    failed due to missing .venv)

  • venv-is-active checked all overlays including inactive ones;
    overlay list in 0.108 includes inactive entries

  • path find-sub returned [] instead of null on no match, causing
    type errors in downstream path join calls; also changed to return
    the deepest ancestor match rather than shallowest, which is the
    expected behavior for nested project directories

Test plan

  • cd into a directory with .__auto-venv.nu trigger + .venv/ → venv activates
  • cd out → venv deactivates without error
  • cd into a directory with trigger but no .venv/ → no crash
  • Tab completion (cd <TAB>) works after the hooks are registered
  • Existing PWD hooks (mise, zoxide, etc.) still fire correctly

- default-hooks: don't wrap existing hooks list in another list;
  this produced an invalid nested type that broke hook evaluation
  and downstream tab completion

- on_enter: remove transient cd operations that triggered spurious
  hook evaluations; overlay use now resolves via NU_LIB_DIRS instead
  of runtime PWD (which nushell 0.108 no longer supports for
  dynamically evaluated code)

- on_enter: guard against missing trigger file

- on_exit: guard overlay hide against inactive overlay

- venv_helpers: filter overlay list to active overlays only
  (overlay list now includes inactive entries in 0.108)

- path_extensions: return null instead of [] on no match to prevent
  type errors in downstream path join calls; return deepest ancestor
  match rather than shallowest
@fdncred
Copy link
Copy Markdown
Contributor

fdncred commented May 8, 2026

If we fix it for v0.108.0 it may not work with the latest version v0.112.2. So, I'd ask you to test your changes on the latest version to see if these changes work. I don't want to patch for a 7 month old version.

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.

2 participants