Not running: exec: -S: invalid option

Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Activity 7 comments · opened Feb 25, 2025 · closed Jun 20, 2025
💡 Likely answer: A maintainer (bcherny, collaborator) responded on this thread — see the highlighted reply below.
andrey@ZUEN37938 MSYS ~
$ claude
/c/Users/andrey/AppData/Roaming/npm/claude: line 11: exec: -S: invalid option
exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]

Changing claude shell script fixes the issue (removing -S, suggested by Claude itself :-D):

if [ -x "$basedir/-S" ]; then
  exec "$basedir/-S" node --no-warnings=ExperimentalWarning --enable-source-maps "$basedir/node_modules/@anthropic-ai/claude-code/cli.mjs" "$@"
else 
  exec -S node --no-warnings=ExperimentalWarning --enable-source-maps "$basedir/node_modules/@anthropic-ai/claude-code/cli.mjs" "$@"
fi

to

if [ -x "$basedir/node" ]; then
  exec "$basedir/node" --no-warnings=ExperimentalWarning --enable-source-maps "$basedir/node_modules/@anthropic-ai/claude-code/cli.mjs" "$@"
else 
  exec node --no-warnings=ExperimentalWarning --enable-source-maps "$basedir/node_modules/@anthropic-ai/claude-code/cli.mjs" "$@"
fi

View original on GitHub ↗

7 Comments

risto-liftoff · 1 year ago

This could be caused by a bug in an older version of pnpm (https://github.com/pnpm/pnpm/issues/5575). If so, the thing to do is to update pnpm.

bcherny collaborator · 1 year ago

Fix landed, going out with the next version

jonathan343 · 1 year ago

Hey @bcherny,
Did this fix end up getting released? I just tried installing npm install -g @anthropic-ai/claude-code@1.0.38 and I'm still getting the following:

$ claude --version
/usr/bin/env: invalid option -- 'S'
Try '/usr/bin/env --help' for more information.
19santosh99 · 1 year ago

I am facing the same issue as

$ claude --version
/usr/bin/env: invalid option -- 'S'
Try '/usr/bin/env --help' for more information.

jonathan343 · 1 year ago

I just tried this with v1.0.43 and it looks like it's resolved!

$ npm install -g @anthropic-ai/claude-code@1.0.43

changed 3 packages in 1s

2 packages are looking for funding
  run `npm fund` for details
$ claude --version
1.0.43 (Claude Code)

Thanks for addressing this issue!

19santosh99 · 1 year ago

works perfect thanks a lot for replying

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.