'Can't upgrade Homebrew packages, "directory not empty"
We use JAMF at work to manage our Macs. It sucks, but it's a security thing. We've hacked the Homebrew install script so that it can be run from a company "App Store" that is provided by JAMF.
We set the ownership of everything to $USER:staff. These are single-user MacBook Pro M1s.
Installation of new packages works without a problem, but upgrading or uninstalling does not.
For example, here's an attempt to upgrade Swift...
COLOSSUS ~ » brew upgrade swift
Warning: Treating swift as a formula. For the cask, use homebrew/cask/swift
==> Upgrading 1 outdated package:
swift 5.5.3 -> 5.6
==> Downloading https://ghcr.io/v2/homebrew/core/swift/manifests/5.6
Already downloaded: /Users/guardian/Library/Caches/Homebrew/downloads/9ce4cd102ee58df196a8a42ec3f05c90ae4b6c9b72a14481e787a67516332da8--swift-5.6.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/swift/blobs/sha256:a6879aa65421
Already downloaded: /Users/guardian/Library/Caches/Homebrew/downloads/351c1cf2d05ce75eee1ac5bc590266d57336ca24708c772d5408e783b4d00952--swift--5.6.arm64_monterey.bottle.tar.gz
==> Upgrading swift
5.5.3 -> 5.6
==> Pouring swift--5.6.arm64_monterey.bottle.tar.gz
^@Error: Directory not empty @ dir_s_rmdir - /private/tmp/d20220408-7181-1rfjuz6
The /private/tmp/d20220408-7181-1rfjuz6
directory ends up being owned by ${USER}:wheel, so that may be the issue. Even if I use our script and set the group to wheel recursively, I still get the same error.
This is baffling, as I can install Homebrew the usual way (which uses group wheel) and upgrades/uninstalls work fine.
Any thoughts on what may be happening?
Solution 1:[1]
Your best bet is to do sudo chown -R "$USER":admin /private/tmp/d20220408-7181-1rfjuz6
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | chenrui |