claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Not running: exec: -S: invalid option

Open AndreyDodonov-EH opened this issue 1 year ago • 1 comments

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

AndreyDodonov-EH avatar Feb 25 '25 11:02 AndreyDodonov-EH

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.

risto-liftoff avatar Jun 12 '25 23:06 risto-liftoff

Fix landed, going out with the next version

bcherny avatar Jun 20 '25 20:06 bcherny

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

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

jonathan343 avatar Jul 01 '25 01:07 jonathan343

I am facing the same issue as

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

19santosh99 avatar Jul 03 '25 05:07 19santosh99

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

$ npm install -g @anthropic-ai/[email protected]

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!

jonathan343 avatar Jul 03 '25 21:07 jonathan343

works perfect thanks a lot for replying

19santosh99 avatar Jul 03 '25 21:07 19santosh99

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.

github-actions[bot] avatar Aug 14 '25 14:08 github-actions[bot]