19

I just installed mtr via Homebrew, and it completed seemingly successfully (i.e., nothing unusual).

MBA% mtr
zsh: command not found: mtr

That's odd. I figured I'd try again:

MBA% brew install mtr
Warning: mtr-0.86 already installed

Okay, maybe it's symlinked as mtr-0.86:

MBA% mtr-0.86
zsh: command not found: mtr-0.86

Nope, okay, maybe it just failed to link:

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

However:

MBA% /usr/local/Cellar/mtr/0.86/sbin/mtr
[Success]

What's going on? Why is Homebrew failing to link (and creating fewer symlinks on relinking for that matter..)?

1
  • 1
    (Keen-eyed may note that mtr needs root. Yes. By [Success] I mean it complained about just that, rather than failing to even run.)
    – OJFord
    Jun 8, 2015 at 13:22

4 Answers 4

20

I saw the same when installing brew 0.86. While most binaries get linked to /usr/local/bin, brew get's linked to /usr/local/sbin. This is absolutely right but you need to extend your path in order to avoid typing the whole path.

export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"

will fix it once and you will need to adjust your .bash_profile to fix it permanently

1
15

For mtr v0.86 and below:

brew install mtr
ln /usr/local/Cellar/mtr/0.86/sbin/mtr /usr/local/bin/mtr
sudo mtr superuser.com

But since mtr v0.87 one more command is needed:

ln /usr/local/Cellar/mtr/0.92/sbin/mtr-packet /usr/local/bin/mtr-packet
1
  • 2
    Actually mtr was already in /usr/local/sbin. The solution of adding /usr/local/sbin to the PATH is better.
    – TuanNguyen
    Mar 8, 2017 at 10:15
2

Add /usr/local/sbin to current PATH variable and make persistent.

export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
echo '/usr/local/sbin' | sudo tee -a /etc/paths
0

Found the answer in stack overflow: https://stackoverflow.com/a/72387809/602072

NOTE: For Apple Silicon machines the PATH is different.

Add this line(s) to .bashrc or .zshrc

# Intel export PATH=$PATH:/usr/local/sbin

# Apple Silicon export PATH=$PATH:/opt/homebrew/sbin 

Run source ~/.bashrc or source ~/.zshrc or close/open your terminal.

Then run mtr as usual

sudo mtr 1.1.1.1 
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .