1

Previously, rsync could simply be upgraded on a Mac to 3.x version by homebrew. As command, I used /usr/local/bin/rsync instead of just rsync (which used the preinstalled 2.x version).

On a MacMini M1, rsync 3.x appears no more in this location but I find it under /opt/homebrew/Cellar/rsync/3.2.6/bin/rsync

So how to use rsync 3.x command now? The location seemingly will change if rsync 3.x was alternatively installed e.g. using MacPorts.

3
  • I don't understand the last paragraph. As for the first you need to alter your PATH to include rsync - I think there is a HomeBrew command to link it into /opt/homebrew/bin
    – mmmmmm
    Sep 18, 2022 at 7:44
  • As far as I understand your comment correctly: you suggest to set the PATH to /opt/homebrew/bin?
    – MacMarkus
    Sep 18, 2022 at 11:07
  • Yes but I think you need another brew coimmand to make a loink in that directory. Putting /opt/homebrew/Cellar/rsync/3.2.6/bin on your PATH would work but then you need to do that for each executable and chnage it when the version or the executable chnages.
    – mmmmmm
    Sep 18, 2022 at 11:12

1 Answer 1

1

Homebrew sets up softlinks in its bin folder specifically to deal with different installed package versions. eg:

~ ls -l $(which rsync)    
lrwxr-xr-x  1 andyg  admin  31 25 Aug 11:49 /opt/homebrew/bin/rsync -> ../Cellar/rsync/3.2.5/bin/rsync

Adding just the /opt/homebrew/bin to the $PATH means you miss out on the man and info pages too. brew shellenv provides the correct path additions. eg.

~ brew shellenv
export HOMEBREW_PREFIX="/opt/homebrew";
export HOMEBREW_CELLAR="/opt/homebrew/Cellar";
export HOMEBREW_REPOSITORY="/opt/homebrew";
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin${PATH+:$PATH}";
export MANPATH="/opt/homebrew/share/man${MANPATH+:$MANPATH}:";
export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}";

You don't use this directly, but a command calling it is added to your shell startup files. So just the correct incantation of the brew shellenv command is needed to setup the relevant env vars. This is what's suggested at the end of the brew install script.... (From a very prominent question in the Related column (64 votes) https://apple.stackexchange.com/a/430904/221742 )

For an M1 Mac (and assuming zsh):

~ echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
~ eval "$(/opt/homebrew/bin/brew shellenv)"

Then (in my experience) close your Terminal, maybe even logoff / on, even though the second command should setup the $PATH immediately for the current session.

This addition has only been required since brew was available for native Apple Silicon, installing to /opt/homebrew. Beforehand the bin was found in the default $PATH. Now it has to be added especially.

By default the Intel installation still goes into /usr/local, with binaries into /usr/local/bin, already in $PATH by default. Be aware there are security risks associated with this method for Intel.

0

You must log in to answer this question.

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