欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

桌面上的 sogou_mac_615b.app 双击可以正常安装,但是 sudo "${HOME}/Desktop/sogou_mac_615b.app/Contents/MacOS/SogouInstaller" 用命令执行 sudo "${HOME}/Desktop/sogou_mac_615b.app/Contents/MacOS/SogouInstaller" 会出问题 chatgpt 有大用 有大大用

#sudo "${HOME}/Desktop/sogou_mac_615b.app/Contents/MacOS/SogouInstaller"   #会出问题,无法安装

No matching processes were found

No matching processes were found

No matching processes were found

No matching processes were found

No matching processes were found

No matching processes were found

No matching processes were found

No matching processes were found

No matching processes were found

sh: /Library/Input Methods/SogouInput.app/Contents/SogouHelper: No such file or directory

chmod: Unable to change file mode on /Library/Input Methods/SogouInput.app: Operation not permitted

mv: rename /var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/com.sogou.pinyin/installer/SogouInput.app/Contents to /Library/Input Methods/SogouInput.app/Contents: Operation not permitted

xattr: [Errno 1] Operation not permitted: '/Library/Input Methods/SogouInput.app'

xattr: [Errno 1] Operation not permitted: '/Library/Input Methods/SogouInput.app'

/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/com.sogou.pinyin/installer/install.sh: line 126: ./SetFile: Bad CPU type in executable

/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/com.sogou.pinyin/installer/install.sh: line 127: ./SetFile: Bad CPU type in executable

/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/com.sogou.pinyin/installer/install.sh: line 128: ./SetFile: Bad CPU type in executable

/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/com.sogou.pinyin/installer/install.sh: line 129: ./SetFile: Bad CPU type in executable

chown: /Library/Input Methods/SogouInput.app: Operation not permitted

chmod: /Library/Input Methods/SogouInput.app/Contents/Resources: No such file or directory

No matching processes were found

No matching processes were found

No matching processes were found

cp: /Library/Input Methods/SogouInput.app/Contents/Resources/symbolset.plist: No such file or directory

sh: /Library/Input Methods/SogouInput.app/Contents/SogouHelper: No such file or directory

sh: /Library/Input Methods/SogouInput.app/Contents/SogouHelper: No such file or directory

sh: /Library/Input Methods/SogouInput.app/Contents/SogouHelper: No such file or directory

sh: /Library/Input Methods/SogouInput.app/Contents/SogouHelper: No such file or directory



我看出问题了 🚨

你是直接用 sudo 去执行 .app 里面的二进制安装器,这会导致几个典型错误:

  1. 权限问题
    macOS 在安装输入法这类需要写入 /Library/Input Methods/ 的程序时,必须通过 系统安装流程(即双击 .app 用 GUI 安装器),这样系统才会授予对应的权限。
    直接用 sudo 执行二进制会遇到:

  • Operation not permitted

  • No such file or directory
    因为 SIP(System Integrity Protection,系统完整性保护)阻止 sudo 在某些目录下写文件。

  • Bad CPU type in executable
    SetFile 是一个 旧版的 PowerPC 或 x86_32 工具,在 Apple Silicon (M1/M2/M3) 或较新的 macOS 上会报错。
    正常安装器会自动绕过或用系统自带的替代方法,但你手动执行时就直接报错了。

  • 路径问题
    你直接执行 Contents/MacOS/SogouInstaller,它会找不到安装脚本里需要的相对路径(比如 SogouHelperResources),所以很多 No such file or directory


  • 正确的做法

    1. 双击运行 .app,用 GUI 安装,这样能触发 macOS 的权限申请(写入输入法目录)。

    2. 如果你一定要命令行安装,可以用:  OK  有大用 

      open "${HOME}/Desktop/sogou_mac_615b.app"


      这样相当于从 Finder 双击运行。

    3. 如果需要静默安装(无人值守),搜狗官方其实没公开支持,但可以尝试:

      sudo installer -pkg /path/to/SogouInput.pkg -target /


      但是前提是你要先解开 .app 里面的 .pkg,看这个版本是否包含。


    要不我帮你写个命令,直接提取出 .pkg 然后用 installer 来安装?这样就能绕开 GUI,全命令行安装。要不要我整理下?

    好 👍 那我帮你整理一个命令行安装 搜狗输入法 的流程。思路是:

    1. .app 里面其实封装了一个 .pkg 安装包;

    2. 我们先把 .pkg 提取出来;

    3. 再用系统的 installer 工具来安装(这是 Apple 官方支持的命令行方式,能正确申请权限,不会遇到 Operation not permitted)。


    操作步骤

    1. 找到 .pkg 文件

    假设你下载的文件是:

    ~/Desktop/sogou_mac_615b.app

    解压它:

    cd ~/Desktop pkgutil --expand-full sogou_mac_615b.app SogouExtracted

    看一下里面内容:

    ls SogouExtracted

    一般会有一个 .pkg 文件,例如 SogouInput.pkg


    2. 用 installer 安装

    执行:

    sudo installer -pkg ~/Desktop/SogouExtracted/SogouInput.pkg -target /

    如果路径不同,把 SogouInput.pkg 换成实际名字。


    3. 验证安装是否成功

    执行:

    ls /Library/Input\ Methods/

    应该能看到 SogouInput.app

    然后去 系统偏好设置 → 键盘 → 输入法 添加 搜狗拼音


    ⚠️ 注意:

    • 在 macOS 10.15+ 系统,安装输入法必须重启一次或注销再登录才会生效。

    • 如果你是 Apple Silicon (M1/M2/M3),最好下载 最新 ARM64 版本的搜狗输入法,不然会有兼容性问题。


    要不要我帮你写一个 一键脚本(直接提取 .pkg 并安装),这样你只要运行一条命令就行?



    普通分类: