Not running: exec: -S: invalid option
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
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.
Fix landed, going out with the next version
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.
I am facing the same issue as
$ claude --version /usr/bin/env: invalid option -- 'S' Try '/usr/bin/env --help' for more information.
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!
works perfect thanks a lot for replying
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.