Skip to content

brew upgrade ruby leaves gems directory with wrong permissions #261905

@rgaufman

Description

@rgaufman

brew config AND brew doctor output OR brew gist-logs <formula> link

(base) Romans-MBP.local ➜  ~  brew config
HOMEBREW_VERSION: 5.0.9
ORIGIN: https://github.com/Homebrew/brew
HEAD: bf65f9c19a7a62abcbdac9c30cf3ff844d0fd633
Last commit: 4 days ago
Branch: stable
Core tap JSON: 08 Jan 21:17 UTC
Core cask tap JSON: 08 Jan 21:17 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_DOWNLOAD_CONCURRENCY: 28
HOMEBREW_EDITOR: nvim
HOMEBREW_FORBID_PACKAGES_FROM_PATHS: set
HOMEBREW_MAKE_JOBS: 14
Homebrew Ruby: 3.4.8 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.4.8/bin/ruby
CPU: 14-core 64-bit arm_palma
Clang: 17.0.0 build 1700
Git: 2.50.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 26.2-arm64
CLT: 26.2.0.0.1.1764812424
Xcode: 26.2
Metal Toolchain: N/A
Rosetta 2: false



(base) Romans-MBP.local ➜  ~  brew doctor
Your system is ready to brew.

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.
  • My issue is not about a failure to build a formula from source.

What were you trying to do (and why)?

After upgrading Ruby via Homebrew, I ran gem pristine --all to restore gems to pristine condition (standard practice after Ruby upgrades to ensure native extensions are rebuilt).

What happened (include all command output)?

$ brew upgrade ruby
  # (upgraded from 3.4.x to 4.0.0)

  $ gem pristine --all
  Restoring gems to pristine condition...
  ERROR:  While executing gem ... (Gem::FilePermissionError)
      You don't have write permissions for the /opt/homebrew/Cellar/ruby/4.0.0/lib/ruby/gems/4.0.0/specifications/abbrev-0.1.2.gemspec directory.

  $ ls -la /opt/homebrew/Cellar/ruby/4.0.0/lib/ruby/gems/4.0.0/specifications/abbrev-0.1.2.gemspec
  -r--r--r-- 1 hackeron 1022 Dec 25 14:20 ...abbrev-0.1.2.gemspec

Files are mode 444 (read-only for everyone, including owner).

What did you expect to happen?

Gem files should be writable by owner (mode 644), allowing normal gem operations without requiring sudo chmod.

Step-by-step reproduction instructions (by running brew commands)

brew upgrade ruby
gem pristine --all
# Observe: Gem::FilePermissionError
ls -la /opt/homebrew/Cellar/ruby/4.0.0/lib/ruby/gems/4.0.0/specifications/*.gemspec
# Observe: -r--r--r-- (mode 444)


Workaround:


sudo chmod -R u+w /opt/homebrew/Cellar/ruby/4.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions