You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All those extra paths — Homebrew, nvm, Go binaries — live in <code>{"~/.zshrc"}</code>, <code>{"~/.zprofile"}</code>, or in scripts those files source. A non-interactive shell never reads any of them.
@@ -146,17 +147,17 @@ echo $PATH`}</code>
146
147
Before changing anything, confirm the symptom. Use <code>zsh -c</code> to simulate what Claude Code sees:
147
148
</p>
148
149
149
-
<pre>
150
-
<code>{`# Does Claude Code's shell see the tool?
150
+
```bash
151
+
# Does Claude Code's shell see the tool?
151
152
zsh -c 'which gh'
152
153
zsh -c 'which go'
153
154
zsh -c 'which node'
154
155
155
156
# Does your interactive shell see it?
156
157
zsh -i -c 'which gh'
157
158
zsh -i -c 'which go'
158
-
zsh -i -c 'which node'`}</code>
159
-
</pre>
159
+
zsh -i -c 'which node'
160
+
```
160
161
161
162
<p>
162
163
The <code>-i</code> flag forces an interactive shell, which sources <code>{"~/.zshrc"}</code>. If <code>zsh -c 'which gh'</code> prints <code>gh not found</code> but <code>zsh -i -c 'which gh'</code> prints the correct path, your PATH export is in <code>{"~/.zshrc"}</code> and you have confirmed the root cause.
Open (or create) <code>{"~/.zshenv"}</code> and add your PATH exports there:
179
180
</p>
180
181
181
-
<pre>
182
-
<code>{`# ~/.zshenv
182
+
```bash
183
+
# ~/.zshenv
183
184
# Sourced for every zsh invocation — interactive, login, and non-interactive alike
184
185
185
186
# Homebrew (Apple Silicon)
@@ -190,23 +191,23 @@ export GOPATH="$HOME/go"
190
191
export PATH="$GOPATH/bin:$PATH"
191
192
192
193
# Local binaries
193
-
export PATH="$HOME/.local/bin:$PATH"`}</code>
194
-
</pre>
194
+
export PATH="$HOME/.local/bin:$PATH"
195
+
```
195
196
196
197
<p>
197
198
For tools that inject themselves via an eval expression in <code>{"~/.zshrc"}</code> — such as <code>nvm</code>, <code>pyenv</code>, or <code>rbenv</code> — you need to move or duplicate that initialization into <code>{"~/.zshenv"}</code> as well:
198
199
</p>
199
200
200
-
<pre>
201
-
<code>{`# ~/.zshenv — nvm initialization for non-interactive shells
201
+
```bash
202
+
# ~/.zshenv — nvm initialization for non-interactive shells
Note the <code>--no-use</code> flag for nvm: it initializes nvm without switching to the default Node.js version, which speeds up shell startup for non-interactive contexts. Remove it if you want the default version active everywhere.
After saving <code>{"~/.zshenv"}</code>, verify without restarting your terminal:
217
218
</p>
218
219
219
-
<pre>
220
-
<code>{`# Reload .zshenv in your current shell
220
+
```bash
221
+
# Reload .zshenv in your current shell
221
222
source~/.zshenv
222
223
223
224
# Confirm Claude Code's shell type now finds the tool
224
225
zsh -c 'which gh'
225
226
zsh -c 'which go'
226
-
zsh -c 'which node'`}</code>
227
-
</pre>
227
+
zsh -c 'which node'
228
+
```
228
229
229
230
<h2>What to Keep in <code>{"~/.zshrc"}</code> vs <code>{"~/.zshenv"}</code></h2>
230
231
@@ -288,8 +289,8 @@ zsh -c 'which node'`}</code>
288
289
Here is a starting point for a <code>{"~/.zshenv"}</code> that covers the most common developer tools on macOS. Adjust paths to match your actual installations:
289
290
</p>
290
291
291
-
<pre>
292
-
<code>{`# ~/.zshenv
292
+
```bash
293
+
# ~/.zshenv
293
294
# Sourced for ALL zsh shells — interactive, login, and non-interactive.
294
295
# Keep this file fast and free of output-producing commands.
295
296
@@ -322,16 +323,16 @@ fi
322
323
# Editor and locale
323
324
export EDITOR="vim"
324
325
export LANG="en_US.UTF-8"
325
-
export LC_ALL="en_US.UTF-8"`}</code>
326
-
</pre>
326
+
export LC_ALL="en_US.UTF-8"
327
+
```
327
328
328
329
<p>
329
330
With this in place, restart Claude Code (or any tool that spawns subshells) and run your verification:
330
331
</p>
331
332
332
-
<pre>
333
-
<code>{`zsh -c 'which gh && which go && which node'`}</code>
334
-
</pre>
333
+
```bash
334
+
zsh -c 'which gh && which go && which node'
335
+
```
335
336
336
337
<p>
337
338
All three should now resolve to their correct paths.
0 commit comments