为什么我在 Homebrew 上卸载/重新安装 Wireshark cask 失败?

问题描述 投票:0回答:1

当我尝试使用 Homebrew 安装 Wireshark Cask 时,一定有什么东西被破坏了,现在它不会卸载或重新安装该程序来尝试修复它。我使用的是运行 MacOS 12.6.3 Monterrey 的 Mac。

这是我在尝试重新安装木桶时从终端收到的输出:

[username]% ~ %brew reinstall --cask wireshark
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/55aa5fe4201426f12464fcae94ebdb6d2303f4c6/Cas
Already downloaded: /Users/[username]/Library/Caches/Homebrew/downloads/8375bbec59fe8490d1a24ab77b3165378f89da8037e1cfc5740524af10db7e66--wireshark.rb
==> Downloading https://2.na.dl.wireshark.org/osx/Wireshark%204.0.7%20Arm%2064.dmg
Already downloaded: /Users/[username]/Library/Caches/Homebrew/downloads/63f9d1988808d4cba46a2f29ffb65b066414802b6368cea4122317942d55d4c8--Wireshark 4.0.7 Arm 64.dmg
==> Uninstalling Cask wireshark
Error: Failure while executing; `/usr/bin/sudo -E -- /usr/sbin/installer -pkg /opt/homebrew/Caskroom/wireshark/4.0.7/Uninstall\ ChmodBPF.pkg -target /` exited with 1. Here's the output:
installer: Package name is Uninstall ChmodBPF
installer: Installing at base path /
installer: The install failed. (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance. An error occurred while running scripts from the package “Uninstall ChmodBPF.pkg”.)

我已经尝试了所有我能想到的方法,包括更新brew、升级brew、更新Xcode。似乎没有什么可以修复这个错误。

macos homebrew wireshark homebrew-cask
1个回答
0
投票

1.找到wireshark .pkg 文件并手动卸载它们。

使用“shift+command+G”到该位置,应该像

/usr/local/Caskroom/wireshark/4.0.10
,里面有四个.pkg文件:

  • 将Wireshark添加到系统路径.pkg
  • 从系统路径中删除 Wireshark.pkg
  • 安装 ChmodBPF.pkg
  • 卸载 ChmodBPF.pkg

注意:不要只运行“删除”和“卸载”.pkgs,否则会出现错误。运行“添加”,然后“删除”,然后“安装”,然后“卸载”。

2.查找并修改.rb文件以忽略有问题的任务

奔跑

brew uninstall --cask wireshark --debug --verbose

输出应如下所示:

==> Uninstalling Cask wireshark
/usr/local/Homebrew/Library/Homebrew/brew.rb (Cask::CaskLoader::FromPathLoader): loading /usr/local/Caskroom/wireshark/.metadata/4.0.10/20231009043133.568/Casks/wireshark.rb
==> Uninstalling Cask wireshark
==> Uninstalling artifacts
==> 46 artifacts defined

/usr/local/Caskroom/wireshark/.metadata/4.0.10/20231009043133.568/Casks/wireshark.rb
就是我们想要的真正的.rb文件。通过您喜欢的任何方法进行编辑。

找到卸载步骤中的段落:

uninstall_preflight do
    system_command "/usr/sbin/installer",
                   args: [
                     "-pkg", "#{staged_path}/Uninstall ChmodBPF.pkg",
                     "-target", "/"
                   ],
                   sudo: true
    system_command "/usr/sbin/installer",
                   args: [
                     "-pkg", "#{staged_path}/Remove Wireshark from the system path.pkg",
                     "-target", "/"
                   ],
                   sudo: true
  end

评论触发pkg的步骤:

uninstall_preflight do
    # system_command "/usr/sbin/installer",
    #                args: [
    #                  "-pkg", "#{staged_path}/Uninstall ChmodBPF.pkg",
    #                  "-target", "/"
    #                ],
    #                sudo: true
    # system_command "/usr/sbin/installer",
    #                args: [
    #                  "-pkg", "#{staged_path}/Remove Wireshark from the system path.pkg",
    #                  "-target", "/"
    #                ],
    #                sudo: true
  end

注意:还有另外两个.rb文件:

/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks/w/wireshark.rb
~/Library/Caches/Homebrew/downloads/4e1d566a28659de840e41ada2b49116e1b15032b7abb525d08f13cd4e268cab0--wireshark.rb
(随机文件名)

这三个.rb文件完全相同。但我不确定自制软件会验证哪个.rb,所以我建议你也修改这两个文件。三个文件内容保持一致.

3.处理自制程序的文件校验和

奔跑

brew uninstall --cask wireshark

输出可能会警告您 .rb 文件校验和不匹配。

复制“预期”SHA256 并在文件中找到它:

~/Library/Caches/Homebrew/api/cask.jws.json

将 json 中的“预期”SHA256 替换为“实际”。

Homebrew 有另一种机制来检查

cask.jws.json
文件,因此我们需要在当前会话中停止 Homebrew 完整性验证功能:

export HOMEBREW_NO_INSTALL_FROM_API=1

您现在应该可以通过

brew uninstall
命令卸载wireshark

© www.soinside.com 2019 - 2024. All rights reserved.