You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

M2芯片MacBook Pro上ZSH环境下SMLNJ安装后运行异常求助

解决M2 MacBook上SMLNJ安装后的命令找不到与运行时错误
  • M系列芯片的Mac,Homebrew默认安装路径是/opt/homebrew而非/usr/local,这是你之前PATH配置错误的核心原因。先执行brew info smlnj --cask,确认官方给出的PATH配置指引。

修正PATH配置

  1. 打开zsh配置文件:open ~/.zshrc
  2. 删除旧的export PATH=/usr/local/Cellar/smlnj/110.79/libexec/bin:$PATH语句,替换为:
    export PATH="/opt/homebrew/opt/smlnj/libexec/bin:$PATH"
    
    这个路径用了brew的软链接,后续版本更新时无需手动修改版本号。
  3. 保存文件后,执行source ~/.zshrc让配置立即生效。

解决运行时找不到的问题

如果修正PATH后仍提示sml: cannot find runtime system,按以下步骤处理:

  1. 检查运行时文件是否存在:
    ls /opt/homebrew/opt/smlnj/libexec/bin/.run/
    
    正常会看到对应arm64架构的文件,比如run.arm64-darwin。
  2. 手动指定运行时启动:
    sml -runtime /opt/homebrew/opt/smlnj/libexec/bin/.run/run.arm64-darwin
    
  3. 永久修复:修改sml启动脚本
    • 找到脚本路径:which sml,一般是/opt/homebrew/opt/smlnj/libexec/bin/sml
    • 打开该脚本,找到架构判断的case分支,添加arm64的处理:
      case "$ARCH" in
        arm64-darwin)
          RUNTIME="$BINDIR/.run/run.arm64-darwin"
          ;;
        x86_64-darwin)
          RUNTIME="$BINDIR/.run/run.x86_64-darwin"
          ;;
        # 保留原有其他架构分支
      esac
      
    • 保存脚本后,直接执行sml即可正常启动。

备选方案:重新安装

如果上述步骤无效,卸载后重装:

  1. 卸载:brew uninstall smlnj --cask
  2. 重装:brew install smlnj --cask
  3. 自动添加PATH:echo 'export PATH="/opt/homebrew/opt/smlnj/libexec/bin:$PATH"' >> ~/.zshrc
  4. 生效配置:source ~/.zshrc

内容的提问来源于stack exchange,提问作者Steven

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 04:10:05