我刚刚mtr
通过 Homebrew 安装,并且它似乎成功完成(即没有什么不寻常的)。
MBA% mtr
zsh: command not found: mtr
这很奇怪。我想我会再试一次:
MBA% brew install mtr
Warning: mtr-0.86 already installed
好的,也许它的符号链接为mtr-0.86
:
MBA% mtr-0.86
zsh: command not found: mtr-0.86
不,好吧,也许只是链接失败:
MBA% brew link mtr
Warning: Already linked: /usr/local/Cellar/mtr/0.86
To relink: brew unlink mtr && brew link mtr
MBA% brew unlink mtr && brew link mtr
Unlinking /usr/local/Cellar/mtr/0.86... 3 symlinks removed
Linking /usr/local/Cellar/mtr/0.86... 2 symlinks created
MBA% mtr zsh: command not found: mtr
然而:
MBA% /usr/local/Cellar/mtr/0.86/sbin/mtr
[Success]
发生了什么事?为什么 Homebrew 链接失败(并且在重新链接时创建的符号链接更少...)?
答案1
我在安装 brew 0.86 时也看到了同样的情况。虽然大多数二进制文件链接到 /usr/local/bin,但 brew 链接到 /usr/local/sbin。这绝对正确,但您需要扩展路径以避免输入整个路径。
export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
会修复一次,你需要调整 .bash_profile 才能永久修复它
答案2
对于 mtr v0.86 及以下版本:
brew install mtr
ln /usr/local/Cellar/mtr/0.86/sbin/mtr /usr/local/bin/mtr
sudo mtr superuser.com
但是从 mtr v0.87 开始需要另外一个命令:
ln /usr/local/Cellar/mtr/0.92/sbin/mtr-packet /usr/local/bin/mtr-packet
答案3
添加/usr/local/sbin
到当前PATH
变量并使其持久化。
export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
echo '/usr/local/sbin' | sudo tee -a /etc/paths
答案4
在 stack overflow 中找到了答案:https://stackoverflow.com/a/72387809/602072
注意:对于 Apple Silicon 机器,PATH 是不同的。
将此行添加到
.bashrc
或.zshrc
# Intel export PATH=$PATH:/usr/local/sbin # Apple Silicon export PATH=$PATH:/opt/homebrew/sbin
运行
source ~/.bashrc
或者source ~/.zshrc
关闭/打开您的终端。然后照常运行 mtr
sudo mtr 1.1.1.1