最近部署了一个包含cluade code的项目,打包镜像选择了老朋友node:20-alpine,在上线后遇到了一个问题,要求cc运行ls -la 的时候报错:
Plain1No suitable shell found. Claude CLI requires a Posix shell environment. Please ensure you have a valid shell installed and the SHELL environment variable set.
检索到的结果发现基本原因是在windows环境下没有bash导致的?但是我是alpine呀,最后也是在cc的issue找到了帖子:
[BUG] Claude will not use /bin/ash on Alpine
[BUG] a POSIX shell is required, but bash is invoked instead
那这么看还是cc优先使用bash的问题,要么给alpine安装bash,要么直接切换node:20-slim,也就解决了。
也就借这个机会又了解了下sh和bash,之前的认知停留在都是命令行解释器,但其实bash是sh的超集,扩展了大量独特的特性;
-
sh(Bourne Shell):
- 最初的 Unix Shell,由 Stephen Bourne 在 1977 年开发
- 是 POSIX Shell 标准的基础
-
bash(Bourne Again Shell):
- 由 Brian Fox 在 1989 年为 GNU 项目开发
- 是 sh 的增强版,完全向后兼容 sh