[BUG] cannot run cd commands with zoxide installed

Status Fixed / completed
Maintainer reply None cached
Activity 4 comments · opened Jun 8, 2025 · closed Jul 9, 2025

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [x] Other: <!-- specify --> Claude Max
  • Claude CLI version: <!-- output of claude --version --> 1.0.17 (Claude Code)
  • Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 --> macOS 15.5
  • Terminal: <!-- e.g. iTerm2, Terminal App --> Terminal App / vscode

Bug Description

<!-- A clear and concise description of the bug -->
⏺ Bash(cd somedir && uv run -m mymodule)
⎿ Error: cd:1: command not found: __zoxide_z

Steps to Reproduce

  1. install zoxide
  2. start zoxide using eval "$(zoxide init --cmd cd zsh)" in .zshrc
  3. run claude and make it run any cd command

Expected Behavior

<!-- What you expected to happen -->
cd commands should get executed successfully

Actual Behavior

<!-- What actually happened -->

  • cd commands fails with command not found: __zoxide_z
  • claude then resorts to using workarounds including bash -c 'cmd' or uv run --directory somedir which succeeds

View original on GitHub ↗

4 Comments

yvesjans · 1 year ago

I'm having the same issue. Added the following workaround for now to my shell config:

if [[ -z "${CLAUDECODE}" ]]; then
  eval "$(zoxide init --cmd cd zsh)"
fi
saravanabalagi · 1 year ago

I tried it, but that's not helping
Also, I have zoxide init already in my .zshrc that would run anyway (outside of if)

saravanabalagi · 1 year ago
  • Found later issues raised with similar error [#2407, #2216]
  • But found a working solution in #2632, check this comment

To summarize, add in .zshrc

[ -z "$DISABLE_ZOXIDE" ] && eval "$(zoxide init --cmd cd zsh)"

and set env var, can be done in ~/.claude/settings.json

{
  "env": {
    "DISABLE_ZOXIDE": "1"
  }
}
github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.