<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[xlings: 新增加XVM版本管理子模块&#x2F;工具 - Rust编写的支持基于目录的工作空间环境隔离]]></title><description><![CDATA[<h1>XVM | Xlings Version Manager - <a href="https://github.com/d2learn/xlings/tree/main/core/xvm" rel="nofollow ugc">Github</a></h1>
<p dir="auto">一个简单且通用的版本管理工具 - 支持多版本管理、支持工作空间和环境隔离、支持多版本的命令别名</p>
<p dir="auto"><img src="/assets/uploads/files/1736259066707-ab7d9843-fa0b-4463-80d9-263392561345-image.png" alt="ab7d9843-fa0b-4463-80d9-263392561345-image.png" class=" img-fluid img-markdown" /></p>
<hr />
<h2>下载安装</h2>
<p dir="auto"><strong>使用xim进行安装</strong></p>
<pre><code class="language-bash">xim --update index
xim -i xvm # 或 xlings install xvm
</code></pre>
<p dir="auto"><strong>直接下载</strong></p>
<blockquote>
<p dir="auto">直接下载压缩包&amp;解压出可执行程序</p>
</blockquote>
<p dir="auto"><a href="https://github.com/d2learn/xlings/releases/tag/xvm-dev" rel="nofollow ugc">release地址</a></p>
<p dir="auto">注: 使用时需要把xvm程序放到一个已经加入PATH的目录里</p>
<h2>基本用法</h2>
<p dir="auto"><strong>xvm add | 添加程序</strong></p>
<blockquote>
<p dir="auto">支持添加不同版本, 也支持创建命令别名</p>
</blockquote>
<pre><code class="language-bash"># xvm add [target] [version] --path [bin-path] --alias [command/bin-file]
xvm add python 2.7.18 --path python2_dir --alias python2
xvm add python 3.12.3 --path python3_dir --alias python3.12
xvm add pv 0.0.1 --alias "python --version"
</code></pre>
<ul>
<li><code>target</code>: 生效时可以使用的命令</li>
<li><code>version</code>: 这个是标识target的版本号, 建议和应用版本保持一致。如果是别名可以自定义</li>
<li><code>--path</code>: 程序所在的实际路径(可选)</li>
<li><code>--alias</code>: 在"所设置的路径"下实际执行的命令(可选), 默认为target</li>
</ul>
<blockquote>
<p dir="auto">注: 默认第一次添加的版本作为全局工作空间的默认版本</p>
</blockquote>
<p dir="auto"><strong>xvm list | 查询程序的所有版本</strong></p>
<blockquote>
<p dir="auto">支持模糊查询</p>
</blockquote>
<pre><code class="language-bash"># xvm list [target]
xvm list python
xvm list p
</code></pre>
<p dir="auto"><strong>xvm use | 切换版本</strong></p>
<blockquote>
<p dir="auto">可以切换到对应的版本, 版本号支持模糊匹配</p>
</blockquote>
<pre><code class="language-bash"># xvm use [target] [version]
xvm use python 3.12.3
xvm use python 2   # -&gt; 2.7.18
</code></pre>
<p dir="auto"><strong>xvm current | 查询当前版本</strong></p>
<blockquote>
<p dir="auto">支持模糊匹配</p>
</blockquote>
<pre><code class="language-bash"># xvm current [target]
xvm current p
</code></pre>
<p dir="auto"><strong>xvm remove | 移除之前被添加的程序</strong></p>
<blockquote>
<p dir="auto">这里的移除只是从xvm的版本数据库中删除记录</p>
</blockquote>
<pre><code class="language-bash"># xvm remove [target] [version]
xvm remove pv 0.0.1
</code></pre>
<h2>工作空间和环境隔离</h2>
<blockquote>
<p dir="auto">目前xvm支持基于目录的工作空间, 可以和全局工作空间进行隔离(默认有一个全局工作空间)</p>
</blockquote>
<h3>基础命令</h3>
<p dir="auto"><strong>创建工作空间</strong></p>
<pre><code class="language-bash"># xvm workspace [target]
xvm workspace test
</code></pre>
<blockquote>
<p dir="auto">注: 工作空间, 默认时激活和继承全局工作空间版本情况的</p>
</blockquote>
<p dir="auto"><strong>设置当前工作空间激活状态</strong></p>
<blockquote>
<p dir="auto">当工作空间未激活时就会使用默认的全局空间, 激活时会覆盖全局空间</p>
</blockquote>
<pre><code class="language-bash"># xvm workspace [target]
xvm workspace test --active false
xvm workspace test --active true
</code></pre>
<p dir="auto"><strong>设置当前工作空间是否继承全局空间</strong></p>
<pre><code class="language-bash"># xvm workspace [target]
xvm workspace test --inherit false
xvm workspace test --inherit true
</code></pre>
<h3>使用场景</h3>
<blockquote>
<p dir="auto">在指定目录创建工作空间, 使用特定的版本</p>
</blockquote>
<pre><code class="language-bash"># 假设全局空间中python使用的版本是3
xvm workspace test # 创建工作空间
xvm use python 2   # 切换python版本
xvm current python # 查询当前版本
python --version   # 验证 - python2
cd ..
python --version   # 返回上级目录/版本会自动切换到全局版本python3
</code></pre>
<h2>其他</h2>
<p dir="auto"><strong>临时关闭xvm版本管理功能</strong></p>
<blockquote>
<p dir="auto">通过设置全局workspace的状态, 可以控制xvm的版本管理是否生效</p>
</blockquote>
<pre><code class="language-bash">xvm workspace global --active false
xvm workspace global --active true
</code></pre>
]]></description><link>http://forum.d2learn.org/topic/62/xlings-新增加xvm版本管理子模块-工具-rust编写的支持基于目录的工作空间环境隔离</link><generator>RSS for Node</generator><lastBuildDate>Wed, 12 Aug 2026 03:17:19 GMT</lastBuildDate><atom:link href="http://forum.d2learn.org/topic/62.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 07 Jan 2025 14:12:49 GMT</pubDate><ttl>60</ttl></channel></rss>