You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS High Sierra安装Homebrew时遇Permission denied @ rb_sysopen错误求助

Fixing Homebrew "Permission denied @ rb_sysopen" on macOS 10.13.3

Hey there, let’s work through this permission error you’re facing with Homebrew. It’s super frustrating when brew doctor says everything’s fine but you still hit roadblocks installing packages like zsh—here are actionable steps to resolve this:

1. Repair Homebrew Directory Permissions

The most common culprit here is incorrect ownership of Homebrew’s core directories. Run this command to take full ownership of all Homebrew-related files and folders:

sudo chown -R $(whoami) $(brew --prefix)/*

This ensures your user account has the access Homebrew needs to write to its directories, which should eliminate the "Permission denied" error for most cases.

2. Upgrade Your Ruby Version

Your system’s default Ruby (2.0.0p648) is quite outdated, and Homebrew relies on Ruby for some internal operations. Let’s install a newer, Homebrew-managed Ruby:

  1. Install Ruby via Homebrew:
    brew install ruby
    
  2. Add the new Ruby to your shell’s PATH so it takes precedence over the system version. For bash users, run:
    echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
    source ~/.bash_profile
    
    For zsh users, replace .bash_profile with .zshrc.
  3. Verify the upgrade with:
    ruby -v
    
    You should see a version like 2.7.x or newer.

3. Refresh and Clean Up Homebrew

Sometimes cached files or partial updates can cause unexpected errors. Run these commands to reset Homebrew’s state:

brew update --force
brew cleanup

After this, try installing zsh again with brew install zsh.

4. Manually Create Missing Directories (If Needed)

If the error message points to a specific missing directory (e.g., /usr/local/var/homebrew), create it manually and set the correct permissions:

sudo mkdir -p /path/to/missing/directory
sudo chown -R $(whoami) /path/to/missing/directory

Replace /path/to/missing/directory with the exact path from your error log.

5. Reinstall Homebrew As a Last Resort

If none of the above works, a clean reinstall might fix underlying corruption. First, uninstall Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

Then reinstall it using the official script:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

内容的提问来源于stack exchange,提问作者noobmaster69

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:15:54