1

I have the reverse case of the other question with the same name (zsh: bad CPU type in executable).

I used the mac moving assistant to go from an M1 to an Intel, and the PHP that is used in my terminal seems to be for the M1 silicon, because I get

zsh: bad CPU type in executable: php

How can I find and uninstall the PHP that is used by -zsh to replace it with a new php?

4
  • Are you looking for instructions on $PATH and the which command to locate command line executables? How to find it will be different than how to uninstall it IMO.
    – bmike
    Commented May 1, 2023 at 13:25
  • don't know how to do either
    – user59971
    Commented May 1, 2023 at 13:30
  • Perfect - and thanks for the clarity. What I'm going to do is get you step one. Once you are OK with what is on the Mac - let's have you ask a second follow on question on what to do if none of the answers have a "next step" that works for you.
    – bmike
    Commented May 1, 2023 at 13:31
  • that is used by -zsh : If you have several PHP versions installed in different directories, you can pick the one you want to use by either fixing the PATH (so that it points to the desired version) or invoke PHP by specifying an explicit path. In any case, unless you have a compelling reason for storing on your Mac a PHP version for a different architecture, consider removing the M1-binary. Commented May 2, 2023 at 6:32

1 Answer 1

1

From your details, what's happened is pretty clear. An installer (or you) selected a non-universal build of php and the migration has caused the breakage.

You can confirm this from your command line with this tool:

which php

You also might check out your $PATH by this command:

echo $PATH

Below is what my Air has for a clean and current OS.

bmike@m2 ~ % echo $PATH
/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
bmike@m2 ~ % sw_vers
ProductName:      macOS
ProductVersion:       13.3.1
BuildVersion:     22E261

The reason for the path is you can inspect any paths that aren't the default (those that differ from the one I posted above) to inspect what else you might have installed that you can watch for / reinstall.

As for removing and reinstalling, I would suggest a far more easy sequence for you:

  1. Make a back up now before changing anything. Time Machine is ideal IMO, but you do what you are most comfortable in for a restore and backup.
  2. Install php for your new architecture. (I saw new since the old install was on Apple Silicon, and you need a new install for Intel, not that one CPU type is newer - this is about you not them.) I would go with homebrew to install brew itself for Intel and then php for Intel (ask a new question if you can't get brew install php to work)
  3. Forget about cleaning up the old php if you can get the new working
  4. Make a backup and then plan your next steps no matter if these worked or not.

The reason to not uninstall is you didn't provide any sort of hint how you got it installed. That would be a different question if you had listed the exact source / steps and wanted just an uninstall. You were focused on getting something working and I find getting a new build is the same as having a few versions of PHP and choosing them - just choose the one you want and forget the old until it's time to clean house with an erase install.

7
  • I can see from that "which" that it came from brew. So apparently, that mac moving assistant managed to move brew as well. and I can run brew, but whenever I try to do something with brew I get "Error: 'git' must be installed and in your PATH! Error: Git is unavailable"
    – user59971
    Commented May 1, 2023 at 14:14
  • Yes - you need to reinstall brew @user59971 - try copying and running the command from brew.sh into a shell where you have run bash to ensure you're using bash for the install and not another install (zsh is now default).
    – bmike
    Commented May 1, 2023 at 14:17
  • anything brew related ends in that error, it says I don't have git
    – user59971
    Commented May 1, 2023 at 14:17
  • 1
    Yes - ask a new question @user59971 - you will need details to fix / uninstall / manage the new install.
    – bmike
    Commented May 1, 2023 at 14:18
  • 1
    I did reinstall CLT, to no avail. And the binary they suggest, same error (those comments are mine - Matt Welander). Opened a new queastion here: apple.stackexchange.com/questions/459356/brew-can-not-find-git
    – user59971
    Commented May 1, 2023 at 14:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .