{"record":{"id":"07164ba15d02fa32","repo":"jdx/mise","slug":"package-plugin-ownership-state-belongs-to-manag","errorCode":null,"errorMessage":"package plugin ownership state {} belongs to manager '{}', not '{manager}'","messagePattern":"package plugin ownership state (.+?) belongs to manager '(.+?)', not '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/plugin.rs","lineNumber":153,"sourceCode":"                packages: BTreeMap::new(),\n            });\n        }\n        let state: PackagePluginState = serde_json::from_str(&crate::file::read_to_string(path)?)\n            .wrap_err_with(|| {\n            format!(\n                \"failed to read package plugin ownership state {}\",\n                crate::file::display_path(path)\n            )\n        })?;\n        if state.schema_version != STATE_SCHEMA_VERSION {\n            bail!(\n                \"unsupported package plugin ownership state version {} in {}\",\n                state.schema_version,\n                crate::file::display_path(path)\n            );\n        }\n        if state.manager != manager {\n            bail!(\n                \"package plugin ownership state {} belongs to manager '{}', not '{manager}'\",\n                crate::file::display_path(path),\n                state.manager\n            );\n        }\n        Ok(state)\n    }\n\n    fn load_state(&self) -> Result<PackagePluginState> {\n        Self::load_state_at(&self.state_path(), &self.name)\n    }\n\n    fn save_state_at(path: &std::path::Path, state: &PackagePluginState) -> Result<()> {\n        crate::file::create_dir_all(path.parent().expect(\"package plugin state parent\"))?;\n        let mut contents = serde_json::to_vec_pretty(state)?;\n        contents.push(b'\\n');\n        crate::file::write_atomic(path, contents)\n    }","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/packages/plugin.rs#L135-L171","documentation":"The persisted package plugin ownership state records which manager wrote it. load_state_at refuses to load a state file whose `manager` field does not match the manager currently requesting it, to avoid one package manager deleting or clobbering another's packages.","triggerScenarios":"The same state file path is used by two different package managers (state.manager differs from the manager argument), e.g. after renaming a manager, switching providers, or copying state between plugin/manager setups.","commonSituations":"Switching a plugin's package manager configuration (e.g. from brew to apt) while old ownership state remains; renaming a manager in config; sharing MISE_DATA_DIR between setups.","solutions":["Delete the ownership state file listed in the error so the new manager starts with clean state","Re-run the package install/prune with the current manager to regenerate matching state","Verify the manager name in your mise config matches the manager that originally wrote the state","Manually uninstall packages tracked by the old manager before switching, then clear the state"],"exampleFix":"// before: state written by 'brew', config now says 'apt'\n# error: ... state ... belongs to manager 'brew', not 'apt'\n// after\nrm ~/.local/share/mise/plugins/myplugin/state.json\nmise plugins packages install myplugin foo   # state recreated for 'apt'","handlingStrategy":"validation","validationCode":"let state: OwnershipState = read_state(path)?;\nif state.manager != current_manager { fs::remove_file(path)?; }","typeGuard":"fn state_belongs_to(s: &OwnershipState, m: &str) -> bool { s.manager == m }","tryCatchPattern":"match plugin.load_state().await {\n    Err(e) if e.to_string().contains(\"belongs to manager\") => {\n        reset_state_for(current_manager); plugin.load_state().await\n    }\n    other => other,\n}","preventionTips":["Keep one manager per plugin; rename managers only after clearing state","Don't copy MISE_DATA_DIR state between machines using different package managers","Uninstall tracked packages before switching a plugin's manager"],"tags":["state-file","ownership-conflict","plugin","package-manager"],"backgroundTag":"invalid-state-transition","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}