dosdude1, Homebrew, Node (and lot of other applications) throwing illegal hardware instruction on patched Catalina (installed on incompatible machine)

Yesterday I decided to give a try in making my old 7.1 MacBook Pro second chance by upgrading macOS to Catalina with IS NOT supported by Apple.

There is a reason why they want drop support for older architecture but You can squeeze last breath if You can allow for sacrifice in stability or compatibility. Upfront I can say that iMovie crash and I was unable to resolve that issue, other applications used for basic web-dev (phpstorm, mysql, nginx, npm) looks and feel working good but still I would not recommend it for profesional work when disruption in workflow cause money or data loss – for any non critical applications, reading email, watching YT it’s worth of trying.

First step is to upgrade patched macOS dosdude1

When You got Your system set up, and try to execute applications installed with Homebrew (in my case it was node) I got this error:

illegal hardware instruction

After investigation, I was able to locate problem. Applications distributed in Homebrew as bottle are compiled for specified architecture. Authors of Homebrew have valid reason to assume that this compiled software is going to be executed on compatible hardware in correlation with macOS version. There is no change of having C2D CPU in Catalina, here is why compiled code is targeted for newer CPU.

Lucky Homebrew have ability for self compiling any packages, but that operation have exactly same (error) outcome as when installing compiled bottle.

answer to this problem, is in telling Homebrew to set target architecture for older CPU-s.

You can edit this file:

nano /usr/local/Homebrew/Library/Homebrew/extend/os/mac/hardware.rb

and change it’s content to

frozen_string_literal: true
module Hardware
def self.oldest_cpu(version = MacOS.version)
if version >= :mojave
:core2
else
generic_oldest_cpu
end
end
end

Notice edited architecture, when OS is greater or equal to Mojave

After that change we can recompile from source our not working applications by using following command.

brew reinstall -s python

-s stands from source

When trying recompile node, I still got error. After more investigation i found out that Node depend on another packages, that are already installed but not recompiled with new directive. Dirty solution i found is to see what node depend on:

brew info npm

and from following code, read dependencies section to recompile all dependent packages with -s

brew reinstall -s pkg-config
brew reinstall -s icu4c
brew reinstall -s python

After that, we can reinstall node

brew reinstall -s npm

After this operation, node works perfect. You can follow same schematic for any other applications that can be found in Homebrew.

11 thoughts on “dosdude1, Homebrew, Node (and lot of other applications) throwing illegal hardware instruction on patched Catalina (installed on incompatible machine)

  1. Wojtek says:

    This actually helped me solve a not working automatic Let’s Encrypt certificate renewal by using a compilation of certbot that didn’t throw this error. Thanks!

  2. Basel Juma says:

    Thank you 🙂

  3. I’m not sure where you’re getting your information,
    but great topic. I needs to spend some time learning much more or understanding more.
    Thanks for great info I was looking for this info for my mission.

  4. Magik says:

    Hi. I am trying to run idevicediagnostics on DOSDUDE Catalina. Macboop Pro 2009
    Upon running I am getting Illegal Instruction error
    `pkmn@pokemons-MacBook bin % idevicediagnostics diagnostics
    zsh: illegal hardware instruction idevicediagnostics diagnostics`
    Any advice as I have trawled google to no avail.
    Thanks.

    • ed says:

      I am using asdf to install elixir, erlang , nodejs and rust.Using this link as a guide.
      https://hexdocs.pm/phoenix/installation.html

      I am getting this when trying to run ‘mix local.hex’ which returns this error.
      $ mix local.hex
      zsh: illegal hardware instruction  mix local.hex

      found this page after searching for zsh: illegal hardware instruction on catalina in google.

      giving me the impression that you might be right about not relying on a my patched 2009 13″ mac pro for dev

      MacBook Pro
        Model Identifier: MacBookPro5,5
        Processor Name: Intel Core 2 Duo
        Processor Speed: 2.53 GHz
        Number of Processors: 1
        Total Number of Cores: 2
        L2 Cache: 3 MB
        Memory: 8 GB
        Boot ROM Version: MBP55.00AC.B03
        SMC Version (system): 1.47f2
        Hardware UUID: D4A3F2E5-21C9-5054-8062-E86FD13CF53C

      in I replaced :nehalem with :core2 and tried to re-run mix local.hex but I still get the same error.

       elsif version >= :mojave
          #  :nehalem
             :core2

  5. Maverick says:

    I still got the issue after using this method on installing PHP

  6. Steve Pearson says:

    Great post, npm/node/angular now working on my patched 2009 MacBookPro5,5. I can hold off spending money on the upgrade for a little while longer.

  7. nikos says:

    Hi thanks for sharing this. Anyone know how to lock this file after install nodejs it’s goes back to previous version and overrides my change.
    Thanks

  8. Thank you very much! I was trying to fix this myself.
    I tried to do “brew edit python@3.9” but your solution is more generic and will make my day for sure.

  9. ed says:

    I am using asdf to install elixir, erlang , nodejs and rust.
    Using this link as a guide.
    https://hexdocs.pm/phoenix/installation.html

    I am getting this when trying to run ‘mix local.hex’ which returns this error.
    $ mix local.hex
    zsh: illegal hardware instruction mix local.hex

    found this page after searching for zsh: illegal hardware instruction on catalina in google.

    giving me the impression that you might be right about relying on a my patched 2009 13″ mac pro.

    MacBook Pro
    Model Identifier: MacBookPro5,5
    Processor Name: Intel Core 2 Duo
    Processor Speed: 2.53 GHz
    Number of Processors: 1
    Total Number of Cores: 2
    L2 Cache: 3 MB
    Memory: 8 GB
    Boot ROM Version: MBP55.00AC.B03
    SMC Version (system): 1.47f2
    Hardware UUID: D4A3F2E5-21C9-5054-8062-E86FD13CF53C

    In /usr/local/Homebrew/Library/Homebrew/extend/os/mac/hardware.rb
    I replaced :nehalem with :core2 and tried to re-run mix local.hex but I still get the same error.

    elsif version >= :mojave
    # :nehalem
    :core2

Leave a Reply to Basel Juma Cancel reply

Your email address will not be published. Required fields are marked *


Warning: Undefined array key 0 in /www/wwwroot/electronicnoobblog.com/wp-content/plugins/wp-google-analytics-scripts/wp-google-analytics-scripts.php on line 602