9

Updated context:

When I tried to run flutter project, but I got the this error Error: To set up CocoaPods for ARM macOS, run: arch -x86_64 sudo gem install ffi

I'd run arch -x86_64 sudo gem install ffi, but still had same issues.

this is information

yomate@Mac-mini yomate % sudo gem install ffi
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin21/rbconfig.rb:230: warning: Insecure world writable dir /Users/yomate/FlutterDev/flutter/bin in PATH, mode 040777
Building native extensions. This could take a while...
Successfully installed ffi-1.15.5
Parsing documentation for ffi-1.15.5
Done installing documentation for ffi after 3 seconds
1 gem installed

How can solve this problem? arch: posix_spawnp: gem: Bad CPU type in executable , environment: Mini M1

When I want to use this commend

sudo arch -x86_64 gem install ffi and sudo arch -x86_64 gem install cocoapods

I had got this error. arch: posix_spawnp: gem: Bad CPU type in executable

And my flutter still had error.

[!] Flutter (Channel stable, 3.0.1, on macOS 12.4 21F79 darwin-arm, locale
    en-AU)
    ✗ Downloaded executables cannot execute on host.
      See https://github.com/flutter/flutter/issues/6207 for more information
3
  • 1
    I'm not sure if that's the fix but try uninstalling the ffi gem and installing it again, this time natively: sudo gem install --user-install ffi, then just flutter run
    – eeqk
    May 28, 2022 at 12:01
  • Having the same error, and @eeqk suggestion didn't fix it. Any additional thoughts?
    – ConleeC
    May 30, 2022 at 21:22
  • @ConleeC make sure your binaries as well as env architectures are aligned, execute arch, flutter doctor and dart --version - they should all return darwin-arm or arm64
    – eeqk
    May 31, 2022 at 7:28

2 Answers 2

12

try with this
sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc
source

0

I was getting the same message on a fresh install of macOS 12.4 on a M1 MBA,

Downloaded executables cannot execute on host.
See https://github.com/flutter/flutter/issues/6207 for more information

Turns out Rosetta wasn't installed yet (I'm guessing the transition to Apple Silicon is almost complete then? haha), and once I installed it the warning went away.

2
  • What method did you use to install Rosetta? Dec 31, 2022 at 3:44
  • I don't remember either by installing an Intel architecture app or through the command line. Jan 18 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.