[BUG] Claude sometimes fails bash commands on paths with spaces (workaround available)
Environment
- Platform (select one):
- [ X ] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 1.0.4 (Claude Code)
- Operating System: macOS 14.4.1
- Terminal: iTerm2
Bug Description
Periodically, Claude Code tries to execute a bash command that involves a path. It does so with the fully specified path, but it does not quote the path. This means that if your path includes spaces -- and mine does -- the bash command will fail. Claude will then spend time and tokens figuring out why.
Steps to Reproduce
Usually this happens when Claude is doing its own thing. For example, right now it is asking for permission to run the following:cd "/Users/me/path with spaces" && python test_a_unit_test.py 2>&1
However, you can reproduce it directly by prompting it:
Please change to the current directory, using the full path, with bash and execute a directory listing.
and it will ask to run:
Bash(cd /Users/you/path with spaces && ls -la)…
Expected Behavior
It is able to run the bash command with the full path.
Actual Behavior
The command line will fail due to a space being interpreted as the end of the command.
Additional Context
It seems intermittent, in that sometimes Claude added quotes, sometimes not. It also happened where sometimes it would use a pattern of changing to the project folder explicitly (maybe it can't easily track where it is?) before running a command, usually for me a unit test.
I solved it locally by adding info to the Claude.md file to quote all paths in bash commands.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗