[BUG] Not honoring SHELL variable when bash is not installed
Resolved 💬 6 comments Opened Mar 12, 2026 by tpimenta-ionos Closed Jun 19, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
when bash is not present commands fails with: Command failed: No suitable shell found. Claude CLI requires a Posix shell environment. Please ensure you have a valid shell installed and the SHELL environment variable set.
even when SHELL is properly set, in that case to /bin/sh which may be a link to dash for debian or ash for alpine.
when embedding /bin/bash to run /bin/sh instead it gives:
! pwd
⎿ /bin/sh: /home/user/.claude/shell-snapshots/snapshot-bash-1773322226470-3377uk.sh: line 4: shopt: not found
/tmp
What Should Happen?
honour the SHELL environment variable to generate the snapshots
Error Messages/Logs
Command failed: No suitable shell found. Claude CLI requires a Posix shell environment. Please ensure you have a valid shell installed and the SHELL environment variable set.
Steps to Reproduce
- Install native claude on Alpine skipping the install script:
docker run --rm -it alpine
# inside the image instance:
apk add -q --no-cache libgcc libstdc++
wget -qO- https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/2.1.74/linux-x64-musl/claude |
install -o 0 -g 0 -m 755 /dev/stdin /usr/local/bin/claude
- Setup and run it on any directory:
mkdir ~/.claude
cp ... ~/.claude/.credentials.json # replate it...
cat > ~/.claude.json <<'EOF'
{
"hasCompletedOnboarding": true,
"theme": "light",
"installMethod": "native",
"autoUpdates": false
}
EOF
# ...
mkdir ~/project
cd $_
export SHELL=/bin/sh
claude
- Select trust this directory
- Run a command such as
!pwd
Claude Model
None
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.74
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Xterm
Additional Information
workaround:
install -o 0 -g 0 -m 755 /dev/stdin /bin/bash <<'EOF'
#!/bin/sh
echo "$(date +%T) $0 $*" >> /tmp/.logs
sed -i -r '/shopt/d' ~/.claude/shell-snapshots/snapshot-bash-*.sh 2> /dev/null || :
exec /bin/sh "$@"
EOF
ideally /tmp/.logs should be empty because if it honour SHELL environment variable there should be no call to other shells.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗