homebrewsymlinkopenconnect

Problem when installing openconnect using brew


I am stuck when trying to install "openconnect" using homebrew because I am not permitted to make the symbolic link to /usr/local/share/locale/ca/LC_MESSAGES. I am running Big Sur version 11.4.

Below follows what I have tried:

(base) MacBook-Pro-5:Data Eigil$ brew uninstall --force openconnect

Uninstalling openconnect... (54 files, 2.8MB)

(base) MacBook-Pro-5:Data Eigil$ brew cleanup -s openconnect

Removing: /Users/Eigil/Library/Caches/Homebrew/openconnect--8.10... (971.3KB)

(base) MacBook-Pro-5:Data Eigil$ brew cleanup --prune-prefix

(base) MacBook-Pro-5:Data Eigil$ brew install openconnect

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
Updated 8 formulae.
==> Updated Casks
Updated 1 cask.

==> Downloading https://ghcr.io/v2/homebrew/core/openconnect/manifests/8.10
Already downloaded: /Users/Eigil/Library/Caches/Homebrew/downloads/c979ec1baea5847f748962ba42b95bce88cef90599731a131c5588090c9c066b--openconnect-8.10.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/openconnect/blobs/sha256:9755c4ea66ed9c8aa1f1ee966c932ec2be37849887636d8f65a920f20c16ec55
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:9755c4ea66ed9c8aa1f1ee966c932ec2be37849887636d8f65a920f20c16ec55?
######################################################################## 100.0%
==> Pouring openconnect--8.10.big_sur.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink share/locale/ca/LC_MESSAGES/openconnect.mo
/usr/local/share/locale/ca/LC_MESSAGES is not writable.

You can try again using:
  brew link openconnect
==> Summary
🍺  /usr/local/Cellar/openconnect/8.10: 54 files, 2.8MB

The suggested solution doesn't work (still because I cannot write to LC_MESSAGES). sudo is not permitted on that directory neither.

ls -l /usr/local/share/locale/ca/

gives:

total 0

drwxr-xr-x  3 root  wheel  96 Jun 28 11:34 LC_MESSAGES/

Any help would be appreciated.


Solution

  • Homebrew is not designed to work with sudo. You should never prepend sudo before command brew, which will change the ownership of some of the brew related files.

    The consequence is that some of the files are not owned by you but by root now. You have to fix the permission.

    # For x86 Mac
    sudo chown -R "$(whoami):admin" /usr/local/*
    
    # For M1 mac
    sudo chown -R "$(whoami):admin" /opt/homebrew/*
    
    # NOTE:
    # * in /usr/local/* is used on purpose to only match the sub folders, files
    # The command will take some time, wait patiently.
    

    You'd better re-install openconnect after above fix.