8

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
Stanley
  • 311
  • 5
  • 15
  • 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 '22 at 12:01
  • Having the same error, and @eeqk suggestion didn't fix it. Any additional thoughts? – ConleeC May 30 '22 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 '22 at 07:28

2 Answers2

12

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

Francesco Iapicca
  • 2,618
  • 5
  • 40
  • 85
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.