<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Mise on Masutaka&#39;s ChangeLog Memo</title>
    <link>https://masutaka.net/en/tags/mise/</link>
    <description>Recent content in Mise on Masutaka&#39;s ChangeLog Memo</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Sat, 30 May 2026 19:18:29 +0900</lastBuildDate>
    <atom:link href="https://masutaka.net/en/tags/mise/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Making Codex CLI and Codex.app Use mise-managed Ruby and Node.js</title>
      <link>https://masutaka.net/en/2026-05-30-1/</link>
      <pubDate>Sat, 30 May 2026 19:18:29 +0900</pubDate>
      <guid>https://masutaka.net/en/2026-05-30-1/</guid>
      <description>&lt;p&gt;I mostly use Claude Code, but lately I&amp;rsquo;ve been using Codex CLI and Codex.app (hereafter &amp;ldquo;Codex&amp;rdquo;) more often too. My environment is macOS.&lt;/p&gt;
&lt;p&gt;However, after I started using &lt;a href=&#34;https://mise.jdx.dev/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;mise&lt;/a&gt;
 in &lt;a href=&#34;https://masutaka.net/en/2026-03-29-1/&#34;&gt;[2026-03-29-1]&lt;/a&gt;
, I ran into trouble because Codex wouldn&amp;rsquo;t use the mise-managed Ruby, Node.js, and so on.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s the state I was in:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-console&#34; data-lang=&#34;console&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ where ruby
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;/usr/bin/ruby
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ ruby --version
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin25]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;the-solution&#34;&gt;The Solution&lt;/h2&gt;
&lt;p&gt;I solved it by adding the following to &lt;code&gt;~/.zshenv&lt;/code&gt;:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I mostly use Claude Code, but lately I&rsquo;ve been using Codex CLI and Codex.app (hereafter &ldquo;Codex&rdquo;) more often too. My environment is macOS.</p>
<p>However, after I started using <a href="https://mise.jdx.dev/" target="_blank" rel="noopener">mise</a>
 in <a href="/en/2026-03-29-1/">[2026-03-29-1]</a>
, I ran into trouble because Codex wouldn&rsquo;t use the mise-managed Ruby, Node.js, and so on.</p>
<p>Here&rsquo;s the state I was in:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ where ruby
</span></span><span style="display:flex;"><span>/usr/bin/ruby
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>$ ruby --version
</span></span><span style="display:flex;"><span>ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin25]
</span></span></code></pre></div><h2 id="the-solution">The Solution</h2>
<p>I solved it by adding the following to <code>~/.zshenv</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-zsh" data-lang="zsh"><span style="display:flex;"><span><span style="color:#75715e"># When Codex CLI and Codex.app run commands, .zshrc&#39;s mise activate zsh doesn&#39;t take effect,</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># so add mise shims to PATH.</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> <span style="color:#f92672">[</span> -n <span style="color:#e6db74">&#34;</span>$CODEX_SANDBOX<span style="color:#e6db74">&#34;</span> <span style="color:#f92672">]</span>; <span style="color:#66d9ef">then</span>
</span></span><span style="display:flex;"><span>  PATH<span style="color:#f92672">=</span><span style="color:#e6db74">${</span>XDG_DATA_HOME<span style="color:#e6db74">}</span>/mise/shims:$PATH
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">fi</span>
</span></span></code></pre></div><p>Here&rsquo;s the state inside Codex after the change:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ where ruby
</span></span><span style="display:flex;"><span>/Users/masutaka/.local/share/mise/shims/ruby
</span></span><span style="display:flex;"><span>/usr/bin/ruby
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span>$ ruby --version
</span></span><span style="display:flex;"><span>ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +PRISM [arm64-darwin25]
</span></span></code></pre></div><h2 id="codexs-command-execution-environment-is-a-sandbox">Codex&rsquo;s Command Execution Environment Is a Sandbox</h2>
<p>I&rsquo;d vaguely suspected this for a while, but it seems Codex&rsquo;s command execution environment runs inside a sandbox.</p>
<p>You can spot the clues from within Codex:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-console" data-lang="console"><span style="display:flex;"><span>$ env | grep CODEX
</span></span><span style="display:flex;"><span>CODEX_CI=1
</span></span><span style="display:flex;"><span>CODEX_SANDBOX=seatbelt
</span></span><span style="display:flex;"><span>CODEX_THREAD_ID=019e7806-6025-7c13-a3c6-a70d41c13905
</span></span></code></pre></div><p>&ldquo;seatbelt&rdquo; refers to Apple Seatbelt, which appears to be macOS&rsquo;s sandboxing mechanism.</p>
<p>&#x1f517; <a href="https://zenn.dev/alesion/articles/37abbfb9f2fa4b" target="_blank" rel="noopener">macOSで手軽にSandbox環境を構築できるApple Seatbeltの実践ガイド</a>
</p>
<blockquote>
<p>しかしながら、Apple Seatbeltは公式にドキュメントを公開されておらず、非推奨とされています。一方で実際には多くのアプリケーションやツールで使用されています。</p>
<p><em>(English translation)</em> However, Apple Seatbelt has no officially published documentation and is considered deprecated. Yet in practice, it&rsquo;s used by many applications and tools.</p>
</blockquote>
<p>I see&hellip;</p>
<p>According to this article, Claude Code also adopts Apple Seatbelt, and I confirmed that it can be enabled with <code>/sandbox</code> (see the <a href="https://code.claude.com/docs/en/sandboxing" target="_blank" rel="noopener">official documentation</a>
).</p>
<p>Coming from a background of being used to Claude Code, Codex&rsquo;s sandbox is hard to wrap my head around, but the following article covers it in detail. Much appreciated.</p>
<p>&#x1f517; <a href="https://zenn.dev/4br4si0n/articles/8dfed37969e8cc" target="_blank" rel="noopener">[Codex] sandbox実行の仕組みと設定方法を完全に理解する</a>
</p>
<p>Codex also seems to restrict network access by default. Come to think of it, I remembered that I&rsquo;d previously set the following in <code>~/.codex/config.toml</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-toml" data-lang="toml"><span style="display:flex;"><span>[<span style="color:#a6e22e">sandbox_workspace_write</span>]
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">network_access</span> = <span style="color:#66d9ef">true</span>
</span></span></code></pre></div><h2 id="the-road-to-the-solution">The Road to the Solution</h2>
<p>At first I tried to solve it with a setting like this in <code>~/.codex/config.toml</code>, but it didn&rsquo;t work:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-toml" data-lang="toml"><span style="display:flex;"><span>[<span style="color:#a6e22e">shell_environment_policy</span>.<span style="color:#a6e22e">set</span>]
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">PATH</span> = <span style="color:#e6db74">&#34;/Users/masutaka/.local/share/mise/shims/ruby:(the existing PATH settings hardcoded here)&#34;</span>
</span></span></code></pre></div><p>As I dug deeper, it occurred to me: &ldquo;Doesn&rsquo;t <code>~/.zshenv</code> get loaded every time, even inside the sandbox? If Codex-related environment variables are defined, I should be able to handle it in <code>~/.zshenv</code>.&rdquo; That led me to the solution.</p>
<p>The reason <code>eval &quot;$(mise activate zsh)&quot;</code> in <code>~/.zshrc</code> doesn&rsquo;t take effect is that <code>~/.zshrc</code> is only loaded for interactive shells. Codex appears to run commands in non-interactive shells, so the settings in <code>~/.zshenv</code>, which is loaded every time zsh starts, are what take effect.</p>
<p>I also came up with the idea of moving <code>eval &quot;$(mise activate zsh)&quot;</code> itself into <code>~/.zshenv</code>, and it did actually work. However, I think this isn&rsquo;t a good approach. The <a href="https://mise.jdx.dev/dev-tools/shims.html" target="_blank" rel="noopener">activate PATH method</a>
 is a mechanism that updates environment variables every time the prompt is displayed, so using it in a non-interactive shell with no prompt falls outside its intended purpose.</p>
<p>mise also recommends shims for non-interactive environments (scripts, IDEs, CI), so I followed that here. It&rsquo;s the same approach of adding shims to <code>PATH</code> that I adopted for Emacs in <a href="/en/2026-03-29-1/">[2026-03-29-1]</a>
.</p>
<p>I wanted to avoid hardcoding <code>PATH</code> into <code>~/.codex/config.toml</code> since that would mean duplicate management with <code>~/.zshenv</code>, so I&rsquo;m glad it settled into a clean form.</p>
<h2 id="conclusion">Conclusion</h2>
<p>I summarized how to make Codex CLI and Codex.app use mise-managed Ruby and Node.js.</p>
<p>I think mise is gradually gaining adoption, but I couldn&rsquo;t find an answer by Googling and wondered how everyone else handles this, so I wrote this short article. I hope it helps someone.</p>
<h2 id="related">Related</h2>
<ul>
<li><a href="https://github.com/masutaka/dotfiles-public/blob/f752b939d030779795b703001d3f65b45e7dd0d8/.zshenv" target="_blank" rel="noopener">My current <code>~/.zshenv</code></a>
</li>
<li><a href="https://github.com/masutaka/dotfiles-public/blob/f752b939d030779795b703001d3f65b45e7dd0d8/.zshrc" target="_blank" rel="noopener">My current <code>~/.zshrc</code></a>
</li>
</ul>
]]></content:encoded>
    </item>
  </channel>
</rss>
