For people running Homebrew (brew), and getting ‘Illegal Instruction: 4’ with certain software, but specifically wget
. They recently switched brew to compile with ‘Nehalem’ instructions. The oldest architecture still officially supported by Mojave.
You can switch back to ‘core2’ instructions by editing /usr/local/Homebrew/Library/Homebrew/extend/os/mac/hardware.rb
. Replace the elsif version
and else
branch result with “:core2” like this:
Code:
# frozen_string_literal: true module Hardware def self.oldest_cpu(version = MacOS.version) if CPU.arch == :arm64 :arm_vortex_tempest elsif version >= :mojave :core2 else :core2 end end end
Add this to /etc/hosts
to break access to the pre-built packages:
Code:
0.0.0.0 homebrew.bintray.com
You can then reinstall wget
from source:
Code:
brew reinstall openssl wget --build-from-source
A “roll your own brew upgrade”; This oneliner will stuff all the upgradable packages on a single brew reinstall
line. Maybe that will work but it may fail with some bash error like a ‘commandline too long’. I had a pretty long list so you’ll probably be fine.
Code:
nice -n20 brew reinstall $(brew upgrade --dry-run | grep -v 'Updating Homebrew...' | grep -v '==> Would upgrade .* outdated packages:' | sed 's/\(.*\) .* .* .*$/\1/g') --build-from-source
To check if you have any other pre-built packages installed, list all ‘internet bottles’ (needs jq):
Code:
brew install jq --build-from-source
brew info --json=v1 --installed | jq -r "map(select(.installed[].poured_from_bottle) | .name) | unique | .[]"
Reinstall all bottles that were not built yourself, but poored from an internet source (needs jq):
Code:
brew install jq --build-from-source
for p in $(brew info --json=v1 --installed | jq -r "map(select(.installed[].poured_from_bottle) | .name) | unique | .[]"); do
nice -n20 brew reinstall $p --build-from-source
done
Oneliner version:
Code:
nice -n20 brew reinstall $(brew info --json=v1 --installed | jq -r "map(select(.installed[].poured_from_bottle) | .name) | unique | .[]") --build-from-source
Adapted from: https://stackoverflow.com/a/55038073/273668
You’ll probably need to run that a couple of times, since dependencies may be poured from an internet bottle.