pmadruga / react-native-clean-project

Automating the clean up of a React Native project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The `brew upgrade` step fails on an M1 Apple silicon chip

m2mathew opened this issue · comments

Background

I'm moving an existing react-native project from a x86 machine to a machine with the M1 Apple Silicon chip. All works fine on the x86 machine.

The Issue

On a M1 MacBook Pro, I see the following error message in the terminal (also pictured below) when I run react-native-clean-project and select "Y" on all options:

ℹ️  STARTED: "brew upgrade"
(node:93071) UnhandledPromiseRejectionWarning: Error:

Task "brew upgrade"
Error: Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!
To rerun under ARM use:
    arch -arm64 brew install ...
To install under x86_64, install Homebrew into /usr/local.
.
Exit code: 1


    at executeTask (/Users/drumsensei/code/mobile-conversations-app/node_modules/react-native-clean-project/source/internals/executor.js:40:11)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async main (/Users/drumsensei/code/mobile-conversations-app/node_modules/react-native-clean-project/source/index.js:47:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:93071) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:93071) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

image

Other useful info

  • This happens if I run it from a locally-installed, up-to-date version or from running npx react-native-clean-project.
  • Running brew upgrade or brew update outside of the react-native-clean-project commands works as expected.

Expected Behavior

Run all commands to their end using commands that work with Apple Silicon.

Brew information

Running which brew shows this in my terminal:

/opt/homebrew/bin/brew

This makes sense for an Apple Silicon installation.

React Native information

React Native info

System

  • OS: macOS 12.6
  • CPU: (10) x64 Apple M1 Max
  • Memory: 603.68 MB / 32.00 GB
  • Shell: 5.8.1 - /bin/zsh

Binaries

  • Node: 14.18.3 - ~/.nvm/versions/node/v14.18.3/bin/node
  • Yarn: 1.22.19 - ~/.nvm/versions/node/v14.18.3/bin/yarn
  • npm: 6.14.15 - ~/.nvm/versions/node/v14.18.3/bin/npm
  • Watchman: 2022.09.12.00 - /opt/homebrew/bin/watchman

Managers

  • CocoaPods: 1.11.3 - /opt/homebrew/bin/pod

SDKs

  • iOS SDK:
    • Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
  • Android SDK: Not Found

IDEs

  • Android Studio: 2021.2 AI-212.5712.43.2112.8815526
  • Xcode: 14.0/14A309 - /usr/bin/xcodebuild

Languages

  • Java: 11.0.16.1 - /usr/bin/javac

npmPackages

  • @react-native-community/cli: Not Found
  • react: 17.0.1 => 17.0.1
  • react-native: 0.64.3 => 0.64.3
  • react-native-macos: Not Found

npmGlobalPackages

  • react-native: Not Found

Thanks for any help! 😇

I believe your homebrew and the packages are installed in the wrong directories. I've attached a link to an article that might be helpful for you to understand the situation.

https://earthly.dev/blog/homebrew-on-m1/

I believe your homebrew and the packages are installed in the wrong directories. I've attached a link to an article that might be helpful for you to understand the situation.

@gagtic Thanks for that. I have homebrew installed in the correct place according to the docs and that article. I included this information in my original issue description.

Brew information
Running which brew shows this in my terminal:
/opt/homebrew/bin/brew
This makes sense for an Apple Silicon installation.

Try the cmd under a rosetta terminal

Closing due to inactivity. Let me know if it's still happening.