jdx/mise · error

package plugin ownership state

Error message

package plugin ownership state {} belongs to manager '{}', not '{manager}'

What it means

The package-plugin ownership state file records which package manager (plugin) wrote it. When `load_state_at` reads a state file whose `manager` field differs from the manager performing the current operation, mise bails out instead of letting one plugin mutate or misattribute another plugin's installed packages. This prevents two package plugins from claiming or uninstalling each other's packages.

Solutions

  1. Remove or archive the ownership state file shown in the message so the correct manager can write fresh state (reinstall its packages afterwards if needed).
  2. Uninstall the packages through the manager named in the message ('belongs to manager X') before switching to the new manager.
  3. Fix plugin configuration so each manager uses a distinct state path (avoid renames that orphan state).
  4. Verify you are invoking mise with the same plugin/config that created the state, not a renamed or duplicate plugin definition.

Example fix

// before: state written by manager 'npm' but operation targets 'pnpm'
rm <state-file-from-message>
pmise install   # current manager now owns and rewrites the state
Defensive patterns

Strategy: validation

Validate before calling

// Verify the state file's manager matches the manager you will operate with
import { readFileSync } from 'node:fs';
const state = JSON.parse(readFileSync(statePath, 'utf8'));
if (state.manager !== expectedManager) {
  console.warn(`State ${statePath} belongs to '${state.manager}', not '${expectedManager}' — migrate or delete it first`);
}

Type guard

const isOwnedBy = (state, manager) => state?.manager === manager;

Try / catch

try { await misePluginUninstall(plugin, pkgs) } catch (e) { if (String(e).includes("belongs to manager")) { const owner = e.message.match(/manager '(.*?)'/)?.[1]; console.error(`Uninstall via '${owner}' first, or remove the state file`); } else throw e; }

Prevention

When it happens

Trigger: Invoking an operation (install, uninstall, prune, status) on plugin B while the ownership state file at that path was last written by plugin A; e.g. after renaming a plugin or switching a package set to a different manager that resolves to the same state path.

Common situations: Renaming or replacing a package plugin in config while old state remains on disk; migrating packages from one plugin to another without clearing state; two plugins configured with colliding state directories; copying mise state between projects using different managers.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/07164ba15d02fa32. Report an issue: GitHub.

Appendix: source

Thrown at src/system/packages/plugin.rs:153

                packages: BTreeMap::new(),
            });
        }
        let state: PackagePluginState = serde_json::from_str(&crate::file::read_to_string(path)?)
            .wrap_err_with(|| {
            format!(
                "failed to read package plugin ownership state {}",
                crate::file::display_path(path)
            )
        })?;
        if state.schema_version != STATE_SCHEMA_VERSION {
            bail!(
                "unsupported package plugin ownership state version {} in {}",
                state.schema_version,
                crate::file::display_path(path)
            );
        }
        if state.manager != manager {
            bail!(
                "package plugin ownership state {} belongs to manager '{}', not '{manager}'",
                crate::file::display_path(path),
                state.manager
            );
        }
        Ok(state)
    }

    fn load_state(&self) -> Result<PackagePluginState> {
        Self::load_state_at(&self.state_path(), &self.name)
    }

    fn save_state_at(path: &std::path::Path, state: &PackagePluginState) -> Result<()> {
        crate::file::create_dir_all(path.parent().expect("package plugin state parent"))?;
        let mut contents = serde_json::to_vec_pretty(state)?;
        contents.push(b'\n');
        crate::file::write_atomic(path, contents)
    }

View on GitHub (pinned to 533346cc37)