Unexpected shell validation failure despite valid $SHELL setting

Status Fixed / completed
Maintainer reply ✓ Yes — wolffiex
Activity 8 comments · opened Mar 12, 2025 · closed Mar 14, 2025
💡 Likely answer: A maintainer (wolffiex, collaborator) responded on this thread — see the highlighted reply below.

Bug Description
claude complains about not having a valid shell, but $SHELL is set to a working zsh

Environment Info

  • Platform: linux
  • Terminal: tmux
  • Version: 0.2.30
  • Feedback ID: 11050e7c-6baa-4cbb-98f2-3ef0532d26d8
❯ echo $SHELL
/nix/store/m7l6yzmflrf9hjs8707lk9nkhi6f73n1-zsh-5.9/bin/zsh

❯ claude
╭────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code research preview! │
│                                            │
│   /help for help                           │
│                                            │
│   cwd: /home/pbozeman/src/svc-example      │
╰────────────────────────────────────────────╯

╭───────────────────────────────────────────────────────────────────────────────────────╮
│ >                                                                                     │
╰───────────────────────────────────────────────────────────────────────────────────────╯
  ! for bash mode · / for commands · esc to undo                         \⏎ for newline


This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: 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.
    at i6.findSuitableShell (file:///nix/store/g2i9z5sij5gsgcly3fcsh9vw20q5ybk2-claude-code-0.2.30/lib/node_modules/@anthropic-ai/claude-code/cli.mjs:339:8036)
    at new i6 (file:///nix/store/g2i9z5sij5gsgcly3fcsh9vw20q5ybk2-claude-code-0.2.30/lib/node_modules/@anthropic-ai/claude-code/cli.mjs:339:5985)
    at i6.getInstance (file:///nix/store/g2i9z5sij5gsgcly3fcsh9vw20q5ybk2-claude-code-0.2.30/lib/node_modules/@anthropic-ai/claude-code/cli.mjs:339:8426)
    at mw (file:///nix/store/g2i9z5sij5gsgcly3fcsh9vw20q5ybk2-claude-code-0.2.30/lib/node_modules/@anthropic-ai/claude-code/cli.mjs:344:1172)
    at aH (file:///nix/store/g2i9z5sij5gsgcly3fcsh9vw20q5ybk2-claude-code-0.2.30/lib/node_modules/@anthropic-ai/claude-code/cli.mjs:1162:14518)
    at cz1.<anonymous> (file:///nix/store/g2i9z5sij5gsgcly3fcsh9vw20q5ybk2-claude-code-0.

View original on GitHub ↗

8 Comments

wolffiex collaborator · 1 year ago

thanks for this report. is /nix/store/m7l6yzmflrf9hjs8707lk9nkhi6f73n1-zsh-5.9/bin/zsh an executable file?

pbozeman · 1 year ago
thanks for this report. is /nix/store/m7l6yzmflrf9hjs8707lk9nkhi6f73n1-zsh-5.9/bin/zsh an executable file?

Yes, I can exec $SHELL.

And just for good measure:

❯ ls -l $SHELL
-r-xr-xr-x 1 root root 857336 Dec 31  1969 /nix/store/m7l6yzmflrf9hjs8707lk9nkhi6f73n1-zsh-5.9/bin/zsh*
wolffiex collaborator · 1 year ago

got it, I think nix does some tricky stuff with the executable bit. I should have a fix for this out tomorrow

wolffiex collaborator · 1 year ago

ok, I added some special logic for this. v0.2.40 is rolling now. can you please re-test and let me know if this is fixed?

pbozeman · 1 year ago

Since this is on nix, it will be far easiest if can just override the nix package and point it at an updated repo and hash. At the time I'm writing this comment, it doesn't look like any of the branches on https://github.com/anthropics/claude-code have 0.2.40, or at least, I can't find it. Is the fix up on a public repo somewhere?

wolffiex collaborator · 1 year ago

This repo is for bug tracking only. The official package is here: https://www.npmjs.com/package/@anthropic-ai/claude-code
You can check your version with claude --version and force update with claude update
We don't support claude updating on nix yet

pbozeman · 1 year ago

The fix works. Thanks.

For anyone else reading this in the future, but before the claud-code has been updated in nixpackages, you can use an overlay to update. To upgrade to other versions, just update the version below, run update, and update to the new hash after it gives it to you after an initial mismatch.

./overlays/claude-code.nix (or wherever you personally put them):

{ inputs, nixpkgs, ... }:

final: prev: {
  claude-code = prev.claude-code.overrideAttrs (oldAttrs: rec {
    version = "0.2.41";
    src = prev.fetchzip {
      url = "https://registry.npmjs.org/@anthropic-ai/claude-code/-/claude-code-${version}.tgz";
      hash = "sha256-HxPdULdggaFeNkRnrqIU2Y7HC6F8UdqRLTl8QiLV8wg=";
    };
  });
}

./overlays/default.nix:

{ inputs
, nixpkgs
, ...
}: {
  overlays = [
    (import ./claude-code.nix {
      inherit inputs nixpkgs;
    })
  ];
}

and in your flake:

import nixpkgs {
  inherit system;
  inherit
    (import ./overlays {
      inherit inputs nixpkgs;
    }) overlays;
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.