Homebrew / install

📥 Homebrew (un)installer
https://brew.sh
BSD 2-Clause "Simplified" License
2.15k stars 1.02k forks source link

Brew install fails - sorbet.rb:4:in `require': cannot load such file -- sorbet-runtime (LoadError) #825

Closed AngeloAvv closed 9 months ago

AngeloAvv commented 9 months ago

OS Version: macOS Ventura 13.5.2

What you were trying to do (and why)

I have a classic CI/CD script that compiles iOS artifacts on a server. It relies on brew to install tools used during the process. It started failing today.

Seems like if you try to install brew multiple times after you already installed it, it will fail

What happened (include command output)

Brew setup fails due to sorbet-runtime. I also tried to install sorbet-runtime manually through gem but it keeps failing. Other people are experiencing my problem as mentioned here

Command output

``` bash
macos-server-zero:~ user$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password)...
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following new directories will be created:
/usr/local/Cellar
/usr/local/Caskroom

Press RETURN/ENTER to continue or any other key to abort:
==> /usr/bin/sudo /bin/mkdir -p /usr/local/Cellar /usr/local/Caskroom
==> /usr/bin/sudo /bin/chmod ug=rwx /usr/local/Cellar /usr/local/Caskroom
==> /usr/bin/sudo /usr/sbin/chown user /usr/local/Cellar /usr/local/Caskroom
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Cellar /usr/local/Caskroom
==> /usr/bin/sudo /usr/sbin/chown -R user:admin /usr/local/Homebrew
==> /usr/bin/sudo /bin/mkdir -p /Users/user/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/user/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown -R user /Users/user/Library/Caches/Homebrew
==> Downloading and installing Homebrew...
HEAD is now at d68e3e563 Merge pull request #16268 from Bo98/ruby3-for-all
==> Downloading https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:02180ca8b8295422ae84921bcf034b7ee8ce5575488bd5e6a37a192e53cd5d34
###################################################################################################################################################################### 100.0%
==> Pouring portable-ruby-3.1.4.el_capitan.bottle.tar.gz
/usr/local/Homebrew/Library/Homebrew/standalone/sorbet.rb:4:in `require': cannot load such file -- sorbet-runtime (LoadError)
    from /usr/local/Homebrew/Library/Homebrew/standalone/sorbet.rb:4:in `'
    from /usr/local/Homebrew/Library/Homebrew/startup.rb:10:in `require_relative'
    from /usr/local/Homebrew/Library/Homebrew/startup.rb:10:in `'
    from /usr/local/Homebrew/Library/Homebrew/global.rb:4:in `require_relative'
    from /usr/local/Homebrew/Library/Homebrew/global.rb:4:in `'
    from /usr/local/Homebrew/Library/Homebrew/brew.rb:18:in `require_relative'
    from /usr/local/Homebrew/Library/Homebrew/brew.rb:18:in `
' Failed during: /usr/local/bin/brew update --force --quiet ```

What you expected to happen

I expect the script to install brew and my CI to complete its job without failing. OS/software haven't been updated since months.

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

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

MikeMcQuaid commented 9 months ago

CC @Bo98 as looks related to Ruby 3 vendoring work.

Bo98 commented 9 months ago

This looks to be something to do with installing over a partially uninstalled Homebrew. Note how mkdir -p /usr/local/Homebrew isn't present which means that /usr/local/Homebrew already exists. Would be good to know the state of things.

I do have one theory where it could break because the installer fetches the latest master but brew update downgrades this to the latest tag while staying in Ruby 3 mode (blind fix at https://github.com/Homebrew/brew/pull/16277). I would have expected that to affect all installs rather than just installs with an already partially existing Homebrew though. 🤷‍♂️

AngeloAvv commented 9 months ago

This looks to be something to do with installing over a partially uninstalled Homebrew. Note how mkdir -p /usr/local/Homebrew isn't present which means that /usr/local/Homebrew already exists. Would be good to know the state of things.

If I perform a full uninstall (by also removing folders the script is not able to delete due to missing sudo permission) and I attempt a reinstall using the default script, everything works fine. But if I try to perform another install, the aforementioned error will occur.

This is awkward because I run my CI into a physical machine and it's complicated to uninstall brew every time the process is finished, that's why I decided to reinstall over and over. But suddenly something changed and now the script is failing.

Bo98 commented 9 months ago

I've merged something that might work. Give it a try again and let me know.

AngeloAvv commented 9 months ago

It's working! Thanks!!