jdx/mise · error

pre_use hook is not implemented

Error message

pre_use hook is not implemented

What it means

The vfox plugin compatibility layer declares a pre_use hook API, but no plugin can actually provide a pre_use implementation: the method is hard-wired to unimplemented!, so calling it always panics. It exists only as a placeholder in the trait surface.

Source

Thrown at crates/vfox/src/hooks/pre_use.rs:26

#[allow(dead_code)]
#[derive(Debug)]
pub(crate) struct PreUseContext {
    pub installed_sdks: IndexMap<String, SdkInfo>,
}

#[derive(Debug)]
pub struct PreUseResponse {
    pub version: Option<String>,
}

impl Plugin {
    pub async fn pre_use(&self, _vfox: &Vfox, _legacy_file: &Path) -> Result<PreUseResponse> {
        debug!("[vfox:{}] pre_use", self.name);
        // let ctx = PreUseContext {
        //     installed_sdks: vfox.list_installed_versions(&self.name)?,
        // };

        unimplemented!("pre_use hook is not implemented");
    }
}

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Avoid relying on pre_use behavior with vfox plugins under mise; configure versions explicitly in mise.toml/.tool-versions instead
  2. Check whether the vfox plugin actually needs a pre-use hook; if so, use an asdf plugin or a mise-native backend that supports the behavior
  3. Implement the hook (build PreUseContext from vfox.list_installed_versions and dispatch to the plugin's Lua pre_use script) and submit a PR

Example fix

// before (crates/vfox/src/hooks/pre_use.rs)
unimplemented!("pre_use hook is not implemented");
// after
let ctx = PreUseContext {
    installed_sdks: vfox.list_installed_versions(&self.name)?,
    legacy_file: _legacy_file.to_path_buf(),
};
self.run_hook("pre_use", ctx).await
Defensive patterns

Strategy: fallback

Validate before calling

// A vfox plugin's pre_use hook will always panic; don't depend on it.
// Instead ensure versions are pinned:
// mise ls swift   # confirm explicit installed version exists

Try / catch

match std::panic::catch_unwind(|| plugin.pre_use(...)) { ... } // only when shelling into plugin dispatch you don't control

Prevention

When it happens

Trigger: Any code path that invokes VfoxPlugin::pre_use — e.g. tool request resolution asking a vfox plugin for legacy-file-driven version switching before use.

Common situations: Users coming from asdf/vfox expecting pre-use version rewriting hooks to work under mise's vfox backend; contributors wiring up hook dispatch hit the panic during testing.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/e6bce6e30b1b4855. Report an issue: GitHub.