Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Bad CPU type in executable" when building a flutter app for iOS from an Intel based Mac with Flutter v3.0.2 #106054

Closed
mikegogovapps opened this issue Jun 15, 2022 · 15 comments
Labels
r: solved Issue is closed as solved

Comments

@mikegogovapps
Copy link

Environment

  • OS: macOS Montgomery - 12.2.1
  • Processor: 2.6 GHz Dual-Core Intel Core i5
  • Flutter version: 3.0.2

Steps to Reproduce

  • Clone flutter v3.0.2
  • Navigate to the hello world sample: cd examples/hello_world
  • Build for iOS: flutter build ios --release --no-codesign
  • Notice the error: bin/internal/shared.sh: line 225: bin/cache/dart-sdk/bin/dart: Bad CPU type in executable

I think this may have something to do with the change:
bb4a5fa#diff-fecfc9dccd8a04f4936b4fa1bf09db14f099197ead58e7633009ac282443c4d0R225

@ebjorklund01
Copy link

I am seeing this error building the app in our github actions, but I am not seeing this when I build locally on my intel mac.

/Users/runner/hostedtoolcache/flutter/3.0.2-stable/x64/bin/internal/shared.sh: line 225: /Users/runner/hostedtoolcache/flutter/3.0.2-stable/x64/bin/cache/dart-sdk/bin/dart: Bad CPU type in executable

 build:
    name: Build Apps
    runs-on: macos-11
    steps:
    - uses: maxim-lobanov/setup-xcode@v1
      with:
        xcode-version: '13.0'
    - uses: actions/checkout@v2
    - uses: actions/setup-java@v1
      with:
        java-version: '11.x'
    - uses: subosito/flutter-action@v1
      with:
        channel: 'stable'
    - run: gem install fastlane
    - run: flutter doctor -v

Still builds fine if I specify flutter 3.0.1.

@mikegogovapps
Copy link
Author

Yup. I'm working around this by reverting to an older version as well (v3.0.0). Just wanted to get this one folks' radar in case I wasn't the only one.
And I also first discovered this when my daily github action build broke last Friday after having made no updates to it or my app.

@Macacoazul01
Copy link
Contributor

Maybe it's similar to what happened on my project #105862

Downgrading to 3.0.1 and upgrading again to 3.0.2 was the only working solution.

@philiparpin
Copy link

We are also experiencing this bug with 3.0.2

@jmagman
Copy link
Member

jmagman commented Jun 16, 2022

@christopherfujino did something change with the packaging in 3.0.2 that could cause the arm version of dart to be served up on x64, if that's what's happening?
I'll investigate more tomorrow.

Is this happening to anyone outside of GitHub actions? Could those scripts be running on an M1 but without Rosetta installed?

What's the output of file bin/cache/dart-sdk/bin/dart?

@huycozy huycozy added the in triage Presently being triaged by the triage team label Jun 16, 2022
@maheshmnj
Copy link
Member

maheshmnj commented Jun 16, 2022

Hi @mikegogovapps, Thanks for filing the issue. I tried to build the hello world app and it seems to build successfully on a m1 mac. Please share the complete output of flutter doctor -v.

What's the output of file bin/cache/dart-sdk/bin/dart?

Can you please share the output of this command as requested above?

logs

mahesh@Maheshs-MacBook-Air-M1 hello_world % flutter build ios --no-codesign --release
Warning: Building for device with codesigning disabled. You will have to manually codesign before deploying to
device.
Building io.flutter.examples.hello-world for device (ios-release)...
Upgrading Info.plist
Warning: Missing build name (CFBundleShortVersionString).
Warning: Missing build number (CFBundleVersion).
Action Required: You must set a build name and number in the pubspec.yaml file version field before submitting to
the App Store.
Running Xcode build...                                                  
 └─Compiling, linking and signing...                         6.4s
Xcode build done.                                           29.9s
Built /Users/mahesh/Documents/flutter/examples/hello_world/build/ios/iphoneos/Runner.app.
flutter doctor -v (mac)
[✓] Flutter (Channel stable, 3.0.2, on macOS 12.4 21F79 darwin-arm, locale en-IN)
    • Flutter version 3.0.2 at /Users/mahesh/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cd41fdd495 (5 days ago), 2022-06-08 09:52:13 -0700
    • Engine revision f15f824b57
    • Dart version 2.17.3
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-32, build-tools 33.0.0-rc4
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

[✓] VS Code (version 1.67.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.42.0

[✓] Connected device (3 available)
    • sdk gphone arm64 (mobile) • emulator-5554 • android-arm64  • Android 11 (API 30) (emulator)
    • macOS (desktop)           • macos         • darwin-arm64   • macOS 12.4 21F79 darwin-arm
    • Chrome (web)              • chrome        • web-javascript • Google Chrome 102.0.5005.61

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

@maheshmnj maheshmnj added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 16, 2022
@huycozy
Copy link
Member

huycozy commented Jun 16, 2022

Providing tests on my local Mac Intel. It can build normally.
It seems that it only happened on Github Actions.

  • OS: macOS Monterey 12.2.1
  • Processor: 2 GHz Quad-Core Intel Core i5
Logs
  • stable 3.0.2
➜  hello_world git:(stable) flutter build ios --release --no-codesign
Warning: Building for device with codesigning disabled. You will have to manually codesign before deploying to device.
Building io.flutter.examples.hello-world for device (ios-release)...
Upgrading Info.plist
Warning: Missing build name (CFBundleShortVersionString).
Warning: Missing build number (CFBundleVersion).
Action Required: You must set a build name and number in the pubspec.yaml file version field before submitting to the App Store.
Running Xcode build...                                                  
 └─Compiling, linking and signing...                         8.6s
Xcode build done.                                           38.7s
Built /Users/huynq/Documents/GitHub/flutter/examples/hello_world/build/ios/iphoneos/Runner.app.
  • master 3.1.0-0.0.pre.1265
➜  hello_world git:(master) flutterm build ios --release --no-codesign
Warning: Building for device with codesigning disabled. You will have to manually codesign before deploying to device.
Building io.flutter.examples.hello-world for device (ios-release)...
Warning: Missing build name (CFBundleShortVersionString).
Warning: Missing build number (CFBundleVersion).
Action Required: You must set a build name and number in the pubspec.yaml file version field before submitting to the App Store.
Running Xcode build...                                                  
 └─Compiling, linking and signing...                        11.7s
Xcode build done.                                           33.9s
Built /Users/huynq/Documents/GitHub/flutter_master/examples/hello_world/build/ios/iphoneos/Runner.app.
flutter doctor -v
[✓] Flutter (Channel stable, 3.0.2, on macOS 12.2.1 21D62 darwin-x64, locale en-VN)
    • Flutter version 3.0.2 at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cd41fdd495 (4 days ago), 2022-06-08 09:52:13 -0700
    • Engine revision f15f824b57
    • Dart version 2.17.3
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-32, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] Android Studio (version 4.1)
    • Android Studio at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7042882/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] Android Studio
    • Android Studio at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-1/203.7185775/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[✓] IntelliJ IDEA Community Edition (version 2020.3.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
    • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.67.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.42.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 102.0.5005.115

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
[✓] Flutter (Channel master, 3.1.0-0.0.pre.1265, on macOS 12.2.1 21D62 darwin-x64, locale en-VN)
    • Flutter version 3.1.0-0.0.pre.1265 at /Users/huynq/Documents/GitHub/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 6671503789 (2 hours ago), 2022-06-15 18:36:08 -0700
    • Engine revision f8c0dc87bc
    • Dart version 2.18.0 (build 2.18.0-189.0.dev)
    • DevTools version 2.14.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] Android Studio (version 4.1)
    • Android Studio at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.7042882/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[!] Android Studio
    • Android Studio at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-1/203.7185775/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] IntelliJ IDEA Community Edition (version 2020.3.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
    • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.68.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.42.0

[✓] Connected device (3 available)
    • Pixel 3a (mobile) • 964AY0WL20 • android-arm64  • Android 12 (API 32)
    • macOS (desktop)   • macos      • darwin-x64     • macOS 12.2.1 21D62 darwin-x64
    • Chrome (web)      • chrome     • web-javascript • Google Chrome 102.0.5005.115

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

@ghost
Copy link

ghost commented Jun 16, 2022

Running into the same issue in GitHub action and it's definitely trying to use an ARM executable on Intel:

Run uname -m
x86_64

Run file /Users/runner/hostedtoolcache/flutter/bin/cache/dart-sdk/bin/dart
/Users/runner/hostedtoolcache/flutter/bin/cache/dart-sdk/bin/dart: Mach-O 64-bit executable arm64

Run flutter doctor
/Users/runner/hostedtoolcache/flutter/bin/internal/shared.sh: line 225: /Users/runner/hostedtoolcache/flutter/bin/cache/dart-sdk/bin/dart: Bad CPU type in executable
Error: Process completed with exit code 1.

@ghost
Copy link

ghost commented Jun 16, 2022

Looking a bit more in the matter I don't think this is a flutter issue, rather a https://github.com/flutter-actions/setup-flutter one. I've been checking what the script does and it doesn't consider the architecture for macos. For 3.0.0 and 3.0.1 the first entry in the releases manifest is the intel one so the intel version is downloaded. For 3.0.2 the first version listed in the manifest is the M1 one therefore the script downloads that.

@ghost
Copy link

ghost commented Jun 16, 2022

Actually, correction, we use https://github.com/subosito/flutter-action instead of the one I linked before. Sorry for the mixup!

@philiparpin
Copy link

philiparpin commented Jun 16, 2022

@robertof-wolt hahah all good probably still an issue with https://github.com/flutter-actions/setup-flutter anyways, right?

@ghost
Copy link

ghost commented Jun 16, 2022

@philiparpin Cannot say for sure without trying, but by looking at its code it should work if the runner is intel, if for some reason the runner would happen to be M1 probably it would fail.

The one we are using https://github.com/subosito/flutter-action has a newer version that properly supports different architectures, that should at least solve @ebjorklund01's issue.

@mikegogovapps
Copy link
Author

@maheshmnj I just tried to recreate this outside of the context of github actions on another Intel Mac and the sample built just fine.

I think @robertof-wolt is right with this really being an issue with how flutter is set up for my github action build.

We are also using https://github.com/subosito/flutter-action so I'll close this issue and continue my troubleshooting with this in mind.

Thanks!

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 16, 2022
@ebjorklund01
Copy link

ebjorklund01 commented Jun 16, 2022

@maheshmnj I just tried to recreate this outside of the context of github actions on another Intel Mac and the sample built just fine.

I think @robertof-wolt is right with this really being an issue with how flutter is set up for my github action build.

We are also using https://github.com/subosito/flutter-action so I'll close this issue and continue my troubleshooting with this in mind.

Thanks!

I followed the advice @robertof-wolt to upgrade https://github.com/subosito/flutter-action to v2 and that fixed the issue for me.

@huycozy huycozy added r: solved Issue is closed as solved and removed in triage Presently being triaged by the triage team labels Jun 17, 2022
@github-actions
Copy link

github-actions bot commented Jul 1, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
r: solved Issue is closed as solved
Projects
None yet
Development

No branches or pull requests

7 participants