Bad cpu type in executable ошибка

I’m trying to install the OS X command line tools, and I’ve tried the beta, and the most recent and nothing is working. Every time I try to use one of the tools something like this happens, my example is make and gnumake as those are what I need right now

-bash: /usr/bin/gnumake: Bad CPU type in executable

-bash: /usr/bin/make: Bad CPU type in executable

note, I am running Yosemite 10.10.4, and my processor is a 2.8 GHz Intel Core i5. If you need any more info be sure to let me know

Some macOS users are reportedly getting the “bad CPU type in executable” error when running commands from the Terminal. This issue is most often met in macOS 10.15 “Catalina” and macOS 11 “Big Sur”.

bad CPU type in executable

As it turns out, this particular issue can occur due to several different common scenarios. Here’s a list of potential culprits that might be triggering this error code:

  • Old, non-compatible programs – Since Catalina, macOS dropped support for 32-bit executables. So if your program did not made it to 64-bit or some of its libraries are still 32-bit, it may not run properly.
  • Rosetta 2 not installed – Apple M1 is an ARM-based chip, different from the Intel processors used in the prior devices. Software needs to be translated from x86 instructions to ARM via Rosetta 2 to be able to run on M1-based devices. Double check that Rosetta 2 is installed on your system.

Update your software

As it turns out, one of the most common instances that might trigger this problem is your software of choice is built for 32-bit system. “bad CPU type in executable”, despite being vague, is just a simple message indicates that your software is not compatible.

Most modern software has a built-in update mechanism, but if it does not, try grabbing the latest version of your software from its official website to see whether the error message goes away.

Install Rosetta 2

When macOS tries to run an app that is not built for Apple-made chip (Apple Silicon), macOS will prompt to install Rosetta 2 to automatically translate the app from x86 to ARM instructions.

But if you run commands in the Terminal, there is no automatic detection for missing Rosetta.

In rare cases, users who recover their Mac from a backup won’t get Rosetta 2 during the restoration process.

If you haven’t been prompted to install Rosetta 2, please manually install it by running the following command.

/usr/sbin/softwareupdate --install-rosetta --agree-to-license

Once you got Rosetta installed, you can run the entire terminal app using Rosetta by opening Get Info on Terminal.app in Finder and check the Open using Rosetta box. This way, Terminal and any command or binary it tries to run will go through Rosetta, so you don’t have to worry about manually open each of them manually.

Find all 32-bit executables in your Mac

Now that you know the problem is all about the software is not compatible with the processor and overall architecture, you may ask : How do I know which program I need to reinstall/replace?

Most, if not all, programs you can run from Terminal app are placed in a system path. $PATH environment variable contains all of those path. Here’s a quick command you can run in Terminal to list any 32-bit binaries in your $PATH on macOS-based device.

find `echo $PATH | tr ":" "n"` -perm +1111 -exec file {} ; | grep i386Code language: PHP (php)

Find all 32-bit executables in your Mac

Replace all of those programs with 64-bit compatible binaries and you should be good to go.

Replace software with native ARM builds

To find programs which are not compatible with the system (64-bit ready), we can go to System Information > Software. Here you have to inspect Applications and Legacy Software section for any 32-bit software as in the screenshot below.

Replace software with native ARM builds

When searching for 64-bit or ARM-native software, look for something with “SiMac” or “Apple Silicon” or “ARM64”.

Fix bad CPU type in executable for Android Studio

If you’re an Android application developer, you should be looking for solutions to fix your code. In that case, ValueInBrief post is an excellent guide, which may save you hours of debugging time. Quick summary, the solution involved setting renderscriptSupportModeEnabled to false or switch from androidx libraries to the old support libraries. Consult the original post for detailed guide.

When macOS tries to run an app that is not built for Apple silicon, macOS will prompt to install Rosetta 2 to automatically translate the app to Apple silicon.

In Terminal, there is no automatic detection for missing Rosetta to run older architecture command line tools.

If you haven’t been prompted for any other app already, manually install Rosetta 2:

softwareupdate --install-rosetta

If you need to run a universal binary in the previous architecture, use arch and specify the architecture. You need to manually specify the architecture for binaries that need to run other binaries that are not built for Apple silicon, like Homebrew.

arch -x86_64 …

e.g. arch -x86_64 brew install packagename

Alternatively, you can run the entire Terminal app using Rosetta by opening Get Info on Terminal.app in Finder and checking ‘Open using Rosetta’. This way will Terminal and every binary it tries to run through Rosetta, so Apple silicon binaries won’t be supported and performance will be impacted, but you don’t need to specify the architecture to run old binaries.

To switch an existing zsh terminal to x86_64 use this command:

arch -x86_64 zsh

MacOS Catalina (v10.15) and newer versions only support 64-bit applications. Additionally, Apple has recently transitioned Macs from Intel’s x86-64 processors to ARM64 architecture.

So, if you’re on an older Mac sporting an Intel chip or you’re trying to run a program coded for the wrong architecture, you’ll face the Bad CPU Type in Executable error.

You can usually solve this error by using the 64-bit version of the program and additionally installing Rosetta if necessary. We’ve detailed these and more solutions in the article below.

What causes the Bad CPU Type in Executable Error?

As stated, 32-bit programs are no longer supported on Macs, starting with macOS Catalina. In addition to this, attempting to run programs designed for Intel processors leads to incompatibility in newer ARM64-based Macs which can also cause this error.

Since 32-bit code or incompatible architecture is no longer acceptable on v10.15 and later, developers should update the source accordingly. As a consumer, you can try some of the solutions we’ve listed below.

Use 64-bit Build

Whether it’s an application or a CLI tool that you’re encountering this error on, the easiest way to resolve it is to use a version compiled for ARM64 architecture.

Sometimes, even after installing the 64-bit version of the program, you may still face this error. In such cases, there are likely additional issues that you can resolve with the solutions listed below.

Set Zsh as Default Shell

Zsh (Z shell) is supposed to be the default login and interactive shell in macOS Catalina and later versions. But sometimes, this may not be the case due to unintentional changes, which can ultimately lead to issues like the Bad CPU Type in Executable error. So, you can set Zsh as the default shell with the following steps:

  1. Click on the Apple Menu and select System Preferences > Users & Groups.
    system-preferences-users-and-groups
  2. Press the lock and input your account credentials.
  3. From the user list on the left pane, control-click your user name and select Advanced Options.
  4. Select Zsh from the Login shell menu and press OK to apply the changes.
    mac-login-shell-users-groups
  5. Press the lock and input your account credentials.
  6. From the user list on the left pane, control-click your user name and select Advanced Options.
  7. Select Zsh from the Login shell menu and press OK to apply the changes.

Install Rosetta 2

You may be aware of the Mac transition to Apple silicon that Tim Cook announced in June 2020. Macs used Intel processors for almost 15 years before recently switching to Apple-designed ARM64 CPUs. Many programs designed to run on Intel processors haven’t yet been revised for the new silicon chips.

Apple understands this, which is why Rosetta, a dynamic binary translator, was reintroduced as Rosetta 2 in macOS Big Sur. The first time you try to run an incompatible program, you will automatically be prompted to install Rosetta 2. Here, you can press Install and input your account credentials to fix the issue. But this is via the GUI.

macos-big-sur-software-update-rosetta-alert

The Terminal doesn’t automatically detect that Rosetta is missing. As such, if you attempt to execute an incompatible program via the terminal, you’ll encounter the Bad CPU Type in Executable error. You can resolve such issues by manually installing Rosetta 2 with the following steps:

  1. Press Command + Spacebar to bring up the spotlight, type terminal, and press Enter.
  2. Execute the following command in the terminal:
    softwareupdate --install-rosetta
    softwareupdate-install-rosetta
  3. Type a and press Enter to accept the license agreement.
  4. You should see a message stating Install of Rosetta 2 finished successfully. As Rosetta works automatically in the background, you should be able to run previously incompatible programs without any issues now.
    install-of-rosetta-2-finished-succesfully

Update macOS

In macOS versions earlier than Monterey 12.1, some binaries were still compiled for x86 processors. But the non-ARM binaries have been updated in the newer versions. So if you’re on an older macOS version, now may be a good time to update your Mac. Here are the steps to do so:

  1. Click on the Apple Menu from the top left corner.
  2. Select System Preferences > Software Update > Upgrade / Update Now.
    Mac os update
  3. Install the latest available update and restart your Mac.

Description

This issue is purely informational (for search engines). macOS 10.15 Catalina can only run 64-bit apps. When downloading an executable from the Releases page, a user may be confused if they only have an Intel CPU, that they may not install the amd64 bit version, and use the 386 version instead. Suggest rename to amd64 to x86_64 in any zip filenames under the Releases tab.

Expected

When I type wsk in the terminal, it runs

Actual

When I type wsk in the terminal, it shows the error message bad CPU type in executable: wsk

Steps to reproduce:

  1. Install macOS 10.15 Catalina (Intel CPU)
  2. Download the OpenWhisk_CLI-latest-mac-386.zip file from
    https://github.com/apache/incubator-openwhisk-cli/releases/tag/latest
  3. Unzip the file
  4. Run wsk

Workaround

Download the OpenWhisk_CLI-latest-mac-amd64.zip bundle instead, and run the wsk executable in there

Suggested Fix

  1. Rename OpenWhisk_CLI-latest-mac-amd64.zip to OpenWhisk_CLI-latest-mac-x86_64.zip

Возможно, вам также будет интересно:

  • Bad allocation ошибка в игре
  • Bad allocation ispring free cam ошибка
  • Bad adaptive filter value 1с ошибка как исправить
  • Backup log прервано с ошибкой
  • Backup database прервано с ошибкой 3013

  • Понравилась статья? Поделить с друзьями:
    0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии