fix(env): pass dependency env to vfox backend plugin hooks#8952
fix(env): pass dependency env to vfox backend plugin hooks#8952
Conversation
When a vfox backend plugin has `depends` on another tool, the dependency installs first but the plugin's Lua hooks (BackendListVersions, BackendInstall, BackendExecEnv) couldn't find the dependency's binaries on PATH. Add a `cmd_env` field to the Vfox struct that, when set, calls `plugin.set_cmd_env()` before executing backend hooks. In VfoxBackend, populate this from `dependency_env()` (already used by go, gem, npm, cargo, spm, dotnet backends) so dependency bin paths are on PATH during version resolution and installation. Closes jdx#8951 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a cmd_env field to the Vfox struct, enabling the propagation of dependency environments to Lua plugins. This ensures that tools executed via cmd.exec() within plugins have the correct environment variables, such as PATH. The changes update the backend_list_versions, backend_install, and backend_exec_env hooks to respect this new configuration. Feedback indicates that the _exec_env method in src/backend/vfox.rs was missed and should also be updated. Furthermore, it is suggested to extend this environment propagation to other hooks like list_available_versions and to move the environment population logic outside the is_backend_plugin conditional for better consistency across all plugin types.
Greptile SummaryThis PR fixes vfox backend plugins that declare Confidence Score: 5/5Safe to merge — correct fix, consistent with existing backend patterns, well-tested with unix guard All three hook-dispatch sites in src/backend/vfox.rs are updated, all six get_sdk() call sites in the vfox crate now use get_sdk_with_env(), the #[cfg(unix)] guard correctly handles the printenv platform difference, and no P0/P1 issues were found. The silent-ignore pattern for dependency_env errors matches the gem backend's own precedent. No files require special attention Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[VfoxBackend hook method called] --> B[Create vfox instance via plugin.vfox]
B --> C[dependency_env config]
C -->|Ok| D[vfox.cmd_env = Some dep_env]
C -->|Err - silently ignored| E[vfox.cmd_env remains None]
D --> F[get_sdk_with_env name]
E --> F
F --> G{cmd_env set?}
G -->|Yes| H[plugin.set_cmd_env env]
G -->|No| I[plugin used as-is]
H --> J[Execute Lua hook]
I --> J
J --> K[Dependency binaries available on PATH in cmd.exec]
Reviews (5): Last reviewed commit: "Merge branch 'main' into cprecioso/depen..." | Re-trigger Greptile |
Move cmd_env population before the is_backend_plugin() branch so traditional vfox plugins also get dependency tools on PATH. Add get_sdk_with_env() helper to consolidate the set_cmd_env pattern across all hook methods. Also add cmd_env to _exec_env which was missed in the initial commit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
printenv is Unix-only; on Windows the pcall fallback would cause the assertion to fail. Guard the test so Windows CI is not broken. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
### 🚀 Features - **(config)** Add Tera template support to miserc.toml by @richardthe3rd in [#8867](#8867) ### 🐛 Bug Fixes - **(env)** include tools-only redactions in `mise env --redacted` by @jakedgy in [#8956](#8956) - **(env)** pass dependency env to vfox backend plugin hooks by @cprecioso in [#8952](#8952) - **(shim)** fix race condition when removing in make_shim, when multiple plugins provide the same shim by @brander-john in [#8947](#8947) - **(spm)** derive API URL from host for self-hosted instances by @ThomasDutartre in [#8955](#8955) - **(task)** resolve env vars in usage tera templates when flags are provided by @jdx in [#8957](#8957) ### 📚 Documentation - **(python)** clarify attestation settings must be under [settings] in mise.toml by @fru1tworld in [#8939](#8939) ### 📦 Registry - added sing-box by @tony-sol in [#8944](#8944) ### Chore - **(ci)** remove auto-draft PR workflow by @jdx in [#8945](#8945) ### New Contributors - @ThomasDutartre made their first contribution in [#8955](#8955) - @jakedgy made their first contribution in [#8956](#8956) - @brander-john made their first contribution in [#8947](#8947) - @fru1tworld made their first contribution in [#8939](#8939)
Summary
dependson another tool, the dependency installs first but the plugin's Lua hooks (BackendListVersions,BackendInstall,BackendExecEnv) couldn't find the dependency's binaries on PATHcmd_envfield to theVfoxstruct that callsplugin.set_cmd_env()before executing backend hooks, populated fromdependency_env()(already used by go, gem, npm, cargo, spm, dotnet backends)Closes #8951
Test plan
crates/vfox/src/vfox.rswith adummy-backendtest fixture plugin that verifiescmd_envpropagation to Lua hooksmise run buildpassesmise --cd crates/vfox run testpasses (64 tests, 0 failures)mise run test:unitpasses (591 tests, 0 failures)🤖 Generated with Claude Code