Fix auto-venv compatibility with nushell 0.108#1252
Conversation
- 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
|
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. |
|
Hmm, valid. I just fixed for the version I was running. Let me build |
|
It already runs |
Tests cover path resolution, hook registration, overlay loading, and condition logic. CI runs on ubuntu and macos using the latest nushell release via hustcer/setup-nu.
default-hooks now uses $env.config? with get -o to avoid column-not-found errors when running under nu-check without a config file. Updated setup-nu action to v3.23 and use working-directory instead of shell:nu cd workaround.
- Export main in test file so toolkit uses `use` resolution (relative to file dir) instead of `source` (fails from repo root) - Match setup-nu version to existing CI (v3.9)
macos-latest (arm64) fails in setup-nu; pin to macos-13 for now. Explicit shell:bash ensures nu is found on PATH.
|
I definitely don't want to have a CI yaml just to test auto-venv. If you want to make changes you should CI how to integrate the existing |
Avoids get -o which may not be available in all nushell versions that the CI tests against.
|
I'll do that over the weekend, and much appreciate the feedback! |
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-hookswrapped the existing PWD hooks list in another list,producing an invalid
list<list<closure>>type that corrupted hookevaluation (and broke tab completion as a side effect)
on_enterused transientcdto resolveoverlay userelative toPWD; nushell 0.108 resolves
overlay useat parse time only, sothis no longer works — removed in favor of NU_LIB_DIRS resolution
on_exitcrashed when the overlay was not active (e.g. activationfailed due to missing .venv)
venv-is-activechecked all overlays including inactive ones;overlay listin 0.108 includes inactive entriespath find-subreturned[]instead ofnullon no match, causingtype errors in downstream
path joincalls; also changed to returnthe deepest ancestor match rather than shallowest, which is the
expected behavior for nested project directories
Test plan
cdinto a directory with.__auto-venv.nutrigger +.venv/→ venv activatescdout → venv deactivates without errorcdinto a directory with trigger but no.venv/→ no crashcd <TAB>) works after the hooks are registered