`mise plugins uninstall` 完全指南:移除插件、保留工具版本与 `--purge` 深度清理 📅 发布时间:2026/9/11 8:32:21 👁 浏览次数: mise plugins uninstall完全指南移除插件、保留工具版本与--purge深度清理【免费下载链接】misedev tools, env vars, task runner项目地址: https://gitcode.com/GitHub_Trending/mi/misemise plugins uninstall是 mise 中用于移除已安装插件的命令它默认只删除插件本身的代码与仓库保留插件已安装的工具版本只有显式传入--purge时才会连同插件的 installs、downloads 与 cache 一并清除。本篇以 docs/cli/plugins/uninstall.md 为骨架结合 src/cli/plugins/uninstall.rs 的完整实现与 e2e/cli/test_plugins_packslip 等测试逐层拆解其语法、别名、参数、底层删除流程与常见实操场景帮助你安全、可控地管理 mise 插件生命周期。命令速览项目说明用法mise plugins uninstall [-a --all] [-p --purge] [PLUGIN]…别名remove、rm效果destructive可能删除或不可逆覆盖文件源码src/cli/plugins/uninstall.rs所属命令组mise plugins [FLAGS] [SUBCOMMAND]别名p/plugin/plugin-list在 src/cli/plugins/uninstall.rs 中该子命令通过usage_rs::Args派生定义并声明了visible_aliases [remove, rm]——这正是mise plugins remove my-tool与mise plugins rm my-tool可以直接使用的来源。命令注释同时明确了默认行为Tool installations are retained by default. Pass--purgeto also remove installs, downloads, and cache associated with the selected plugins.注意mise plugins uninstall移除的是插件提供安装/环境逻辑的代码与mise uninstall卸载某个工具的具体版本是两回事下文会详细区分。参数与标志[PLUGIN]…—— 要移除的一个或多个插件位置参数可同时传入多个插件名逐个执行卸载。例如mise plugins uninstall my-tool mise plugins uninstall my-tool another-tool在实现中plugin: VecString会被依次遍历对每个名字先调用unalias_backend归一化再执行卸载逻辑见 src/cli/plugins/uninstall.rs。-a, --all—— 移除所有插件不传插件名、直接列出全部已安装插件并逐个卸载。该标志与位置参数互斥源码中标注为conflicts plugin见 src/cli/plugins/uninstall.rsmise plugins uninstall --all--all模式下插件列表来自install_state::list_plugins()见 src/cli/plugins/uninstall.rs即 src/toolset/install_state.rs 中读取的安装状态快照。由于该模式会一次性清空所有插件建议配合mise plugins ls先确认当前安装清单。-p, --purge—— 连带清除安装、下载与缓存在移除插件代码之外进一步删除该插件后端关联的installs_path、cache_path、downloads_path三个目录。对应底层实现位于 src/backend/mod.rsfn purge(self, pr: dyn SingleReport) - eyre::Result() { remove_all_with_progress(self.ba().installs_path, pr)?; remove_all_with_progress(self.ba().cache_path, pr)?; remove_all_with_progress(self.ba().downloads_path, pr)?; Ok(()) }也就是说--purge会真正回收磁盘空间而默认卸载不会。默认的downloads目录~/.local/share/mise/downloads本身在安装/卸载后通常会被清理见 docs/directories.md--purge主要针对的是 installs 与 cache 中遗留的产物。-h, --help—— 打印帮助输出该子命令的完整用法、别名与参数说明与 docs/cli/plugins/uninstall.md 内容一致。默认行为只删插件保留工具安装这是本命令最核心、也最容易混淆的设计。文档原文明确写道Tool installations are retained by default. Pass--purgeto also remove installs, downloads, and cache associated with the selected plugins.即默认情况下mise plugins uninstall my-tool之后~/.local/share/mise/plugins/my-tool插件代码/仓库被删除~/.local/share/mise/installs/my-tool/*已安装的工具版本依然保留对应工具的下载与缓存也保留。因此在使用上docs/plugin-usage.md 给出了明确的实操建议mise plugin remove my-plugin并且强调被保留的工具版本可能仍需要该插件来解析其可执行文件路径或环境变量。如果不再需要这些工具应先用mise uninstall卸载多余的工具版本再移除插件对单工具插件mise plugin remove --purge my-plugin才会连带清掉 installs、downloads 与 cache。最后如果不再需要该集成应同时删除mise.toml中对应的[plugins]与[tools]条目。底层卸载流程源码级解析mise plugins uninstall的处理链分为三层理解它有助于预判命令的实际影响。1. 命令行入口收集目标并逐个卸载src/cli/plugins/uninstall.rs 的run()先确定目标插件集合--all为真时取install_state::list_plugins()的全部键否则直接使用位置参数列表。随后对每个名字执行unalias_backend归一化见 src/backend/mod.rsdotnet-core→dotnet、nodejs→node、golang→go并剥掉core:前缀。这一步骤确保用户用习惯的别名书写时也能命中正确的插件。2. 单插件卸载存在性检查 删除uninstall_onesrc/cli/plugins/uninstall.rs的逻辑是通过plugins::get(plugin_name)解析插件若插件未安装输出warn!({} is not installed, ...)后直接返回不视为错误若已安装创建进度报告前缀为plugin:name调用plugin.uninstall(pr)若同时指定了--purge再调用backend::get(plugin_name).purge(pr)最后以uninstalled消息结束进度条。其中PluginEnum::uninstall会对 asdf、vfox、vfox-backend 与 package 四类插件统一分派见 src/plugins/mod.rs。3. 不同插件类型的卸载差异asdf 插件src/plugins/asdf_plugin.rs先检查is_installed()随后执行pre-plugin-remove钩子对应插件目录bin/pre-plugin-remove见 docs/asdf-legacy-plugins.md再通过remove_git_plugin_source删除插件源。vfox 插件src/plugins/vfox_plugin.rs额外处理了内嵌插件场景——如果插件是 mise 内嵌的且磁盘上没有对应目录则输出plugin:name is embedded in mise, cannot uninstall的警告并跳过内嵌插件不可卸载。package 插件uninstall为空操作见 src/plugins/mod.rs。remove_git_plugin_sourcesrc/plugins/mod.rs会同时删除插件目录以及若存在其托管 Git 仓库路径确保插件代码完全清除。实操示例卸载单个插件保留工具版本mise plugins uninstall my-tool # 等价写法 mise plugins remove my-tool mise plugins rm my-tool卸载后可用以下命令验证mise plugins ls # 确认 my-tool 不再出现在列表中 mise where my-tool # 确认工具安装目录是否仍保留一次性移除所有插件mise plugins uninstall --all彻底清理插件 安装 下载 缓存mise plugins uninstall my-tool --purge # 或 mise plugins remove --purge my-tool这会删除installs、downloads与cache中与该插件后端关联的目录适合在确认不再使用该工具后回收磁盘空间。结合配置清理如果插件来源写在配置中还需移除相应条目否则下次mise install/mise use可能重新拉取# mise.toml 中删除对应条目 [plugins] # my-tool https://github.com/your-org/my-tool-plugin [tools] # my-tool 2.0.0与相关命令的分工命令作用典型场景mise plugins uninstall [PLUGIN]…移除插件代码默认保留工具安装不再需要某个自定义安装/环境逻辑mise plugins uninstall --purge [PLUGIN]…插件 installs/downloads/cache 一并清除完全弃用该工具回收磁盘mise uninstall TOOLVERSION卸载工具的具体版本只清理工具版本、保留插件mise plugins install [PLUGIN]安装插件与 uninstall 配对的生命周期起点mise plugins update [PLUGIN]更新插件源码升级插件实现不动工具版本mise plugins ls列出已安装插件卸载前确认清单生命周期关系可概括为installdocs/cli/plugins/install.md→updatedocs/cli/plugins/update.md→uninstall。注意update更新的是插件代码而非工具版本uninstall默认保留工具版本——两者都遵循插件与工具版本相互独立的设计原则。目录结构与清理边界根据 docs/directories.md~/.local/share/mise/plugins插件安装目录mise plugins uninstall直接作用于此~/.local/share/mise/installs工具安装目录如installs/node/24.0.0默认卸载不删除~/.local/share/mise/downloads下载产物目录安装/卸载后默认清理--purge会显式清除残留~/.cache/mise缓存目录--purge会删除关联缓存mise cache clear可用于整体清理元数据缓存。所有路径均可通过MISE_DATA_DIR、MISE_CACHE_DIR等环境变量或XDG_*变量覆盖。默认的插件目录写法见 docs/directories.mdmkdir -p ~/.local/share/mise/plugins ln -s ~/src/mise-my-tool ~/.local/share/mise/plugins/my-tool测试验证仓库中的端到端测试直接覆盖了本命令的两种典型场景见 e2e/cli/test_plugins_packslip第 30-32 行安装外部 vfox 插件后执行mise plugins uninstall external-bfs并断言插件元数据文件metadata.lua不再存在第 66-67 行mise plugins uninstall bfs后断言插件目录不存在第 80-81 行再次mise plugins uninstall bfs后重新安装验证可重复的安装/卸载生命周期。这些测试印证了卸载后插件目录被真正删除、同名插件可以再次安装、且整个流程可幂等重复。zsh 补全测试e2e/cli/test_completion_dynamic也覆盖了mise plugins uninstall的动态补全。安全提示本命令标注为destructive--purge会不可逆删除 installs、downloads 与 cache执行前请确认不再需要相关工具版本保留的工具版本若仍被mise.toml引用可能因插件缺失而无法解析可执行路径或环境见 docs/plugin-usage.md建议先mise uninstall清理无用版本插件代码在安装和使用期间以你的权限运行docs/plugin-usage.md卸载时同样可能触发pre-plugin-remove钩子请确保插件来源可信后再安装。小结mise plugins uninstall是一个默认保守、可选激进的插件移除命令不带--purge时只删除插件代码并保留工具安装适合切换插件实现或临时停用集成带--purge时连同 installs、downloads、cache 一起清理适合彻底弃用。理解其与mise uninstall、mise plugins install/update的分工以及 asdf/vfox 插件在卸载钩子与内嵌插件上的差异就能安全、精准地管理 mise 的插件生命周期。【免费下载链接】misedev tools, env vars, task runner项目地址: https://gitcode.com/GitHub_Trending/mi/mise创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考