expo / eas-cli

Fastest way to build, submit, and update iOS and Android apps
https://docs.expo.dev/eas/
MIT License
828 stars 84 forks source link

Error building Expo app on iOS with "sharp" package #1728

Closed garrettg123 closed 1 year ago

garrettg123 commented 1 year ago

Build/Submit details page URL

https://expo.dev/accounts/garrettg/projects/blogcast/builds/17a58368-c5a0-415a-9e98-e56c389b06c6

Summary

I am trying to build my Expo app for iOS using the eas build --platform ios command, but I am encountering an error related to the "sharp" package. The error message I receive is:

[stderr] 
error /Users/expo/workingdir/build/node_modules/sharp: Command failed.
[stderr] 
Exit code: 1
[stderr] 
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
[stderr] 
Arguments: 
[stderr] 
Directory: /Users/expo/workingdir/build/node_modules/sharp
[stderr] 
Output:
[stderr] 
sharp: Detected globally-installed libvips v8.13.3
[stderr] 
sharp: Building from source via node-gyp
[stderr] 
gyp info it worked if it ends with ok
[stderr] 
gyp info using node-gyp@5.1.0
[stderr] 
gyp info using node@14.19.1 | darwin | arm64
[stderr] 
gyp info find Python using Python version 3.9.6 found at "/Applications/Xcode.app/Contents/Developer/usr/bin/python3"
[stderr] 
gyp http GET https://nodejs.org/download/release/v14.19.1/node-v14.19.1-headers.tar.gz
[stderr] 
gyp http 200 https://nodejs.org/download/release/v14.19.1/node-v14.19.1-headers.tar.gz
[stderr] 
gyp http GET https://nodejs.org/download/release/v14.19.1/SHASUMS256.txt
[stderr] 
gyp http 200 https://nodejs.org/download/release/v14.19.1/SHASUMS256.txt
[stderr] 
gyp info spawn /Applications/Xcode.app/Contents/Developer/usr/bin/python3
[stderr] 
gyp info spawn args [
[stderr] 
gyp info spawn args   '/Users/expo/.nvm/versions/node/v14.19.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
[stderr] 
gyp info spawn args   'binding.gyp',
[stderr] 
gyp info spawn args   '-f',
[stderr] 
gyp info spawn args   'make',
[stderr] 
gyp info spawn args   '-I',
[stderr] 
gyp info spawn args   '/Users/expo/workingdir/build/node_modules/sharp/build/config.gypi',
[stderr] 
gyp info spawn args   '-I',
[stderr] 
gyp info spawn args   '/Users/expo/.nvm/versions/node/v14.19.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
[stderr] 
gyp info spawn args   '-I',
[stderr] 
gyp info spawn args   '/Users/expo/Library/Caches/node-gyp/14.19.1/include/node/common.gypi',
[stderr] 
gyp info spawn args   '-Dlibrary=shared_library',
[stderr] 
gyp info spawn args   '-Dvisibility=default',
[stderr] 
gyp info spawn args   '-Dnode_root_dir=/Users/expo/Library/Caches/node-gyp/14.19.1',
[stderr] 
gyp info spawn args   '-Dnode_gyp_dir=/Users/expo/.nvm/versions/node/v14.19.1/lib/node_modules/npm/node_modules/node-gyp',
[stderr] 
gyp info spawn args   '-Dnode_lib_file=/Users/expo/Library/Caches/node-gyp/14.19.1/<(target_arch)/node.lib',
[stderr] 
gyp info spawn args   '-Dmodule_root_dir=/Users/expo/workingdir/build/node_modules/sharp',
[stderr] 
gyp info spawn args   '-Dnode_engine=v8',
[stderr] 
gyp info spawn args   '--depth=.',
[stderr] 
gyp info spawn args   '--no-parallel',
[stderr] 
gyp info spawn args   '--generator-output',
[stderr] 
gyp info spawn args   'build',
[stderr] 
gyp info spawn args   '-Goutput_dir=.'
[stderr] 
gyp info spawn args ]
[stderr] 
gyp info spawn make
[stderr] 
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
[stderr] 
  TOUCH Release/obj.target/libvips-cpp.stamp
[stderr] 
  CC(target) Release/obj.target/nothing/node_modules/node-addon-api/nothing.o
[stderr] 
  LIBTOOL-STATIC Release/nothing.a
[stderr] 
env: python: No such file or directory
[stderr] 
make: *** [Release/nothing.a] Error 127
[stderr] 
gyp ERR! build error 
[stderr] 
gyp ERR! stack Error: `make` failed with exit code: 2
[stderr] 
gyp ERR! stack     at ChildProcess.onExit (/Users/expo/.nvm/versions/node/v14.19.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
[stderr] 
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
[stderr] 
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:282:12)
[stderr] 
gyp ERR! System Darwin 21.6.0
[stderr] 
gyp ERR! command "/Users/expo/.nvm/versions/node/v14.19.1/bin/node" "/Users/expo/.nvm/versions/node/v14.19.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
[stderr] 
gyp ERR! cwd /Users/expo/workingdir/build/node_modules/sharp
[stderr] 
gyp ERR! node -v v14.19.1
[stderr] 
gyp ERR! node-gyp -v v5.1.0
[stderr] 
gyp ERR! not ok
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
yarn exited with non-zero code: 1

Managed or bare?

bare

Environment

expo-env-info 1.0.5 environment info: System: OS: macOS 13.2 Shell: 3.0.2 - /usr/local/bin/fish Binaries: Node: 16.18.1 - /usr/local/bin/node Yarn: 1.22.5 - ~/.yarn/bin/yarn npm: 9.4.0 - /usr/local/bin/npm Watchman: 2023.02.13.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: API Levels: 30, 31, 32, 33 Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 33.0.0, 33.0.1 System Images: android-30 | Google Play Intel x86 Atom, android-33 | Google APIs ARM 64 v8a, android-33 | Google APIs Intel x86 Atom_64 IDEs: Android Studio: 2022.1 AI-221.6008.13.2211.9514443 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Expo Workflow: bare

Error output

No response

Reproducible demo or steps to reproduce from a blank project

  1. Create an expo project with the sharp module installed in a separate yarn workspace package
  2. Run eas build and choose to use the new m1 build
wkozyra95 commented 1 year ago

env: python: No such file or directory

sharp does not provide prebuilds for m1, so it tries to build from the source. Python should be installed on M1, but image you are using is on macos version that already removed python2, so you might try on the older one.

Or if you do not use sharp in mobile app, you can set up your project in a way that does not install dependencies. e.g you can keep everything in the same repo without using workspaces.

mikealche commented 1 year ago

Hey I'm having exactly the same issue! I use a workspace and another project in the workspace uses sharp.

@wkozyra95 Forgive me because I'm not very good at configuring this tooling, could you be a bit more explicit on how to change the base image for the eas build ? Is there a way to still use workspaces but to tell expo that it should only install dependencies for the mobile app? (not for every other project in the workspace?)

evansendra commented 1 year ago

@mikealche did you figure out a solve for this issue? Facing a similar issue now

egecavusoglu commented 11 months ago

ey oh ey oh, if you're in a monorepo setup and some other package is using sharp this might be hapenning. Expo detects yarn workspaces and runs a yarn install, which builds every damn dependency(!) and sharp is a p in the a to build cuz of c++ whatever it wants to use. I guess you can

I remember mr. @byCedric to be the monorepo expert so he might know the real solution to this, which is how do I tell expo to only build dependencies that my expo project uses instead of whole damn dependencies of the monorepo.

cheers

Nantris commented 9 months ago

Is there any solution to this? It doesn't seem to happen on every build, but it wastes a lot of builds just trying to figure out the pattern, if there is one.

Previously we never had any trouble with including Sharp in our monorepo.

Edit: It seems possible setting SHARP_IGNORE_GLOBAL_LIBVIPS: 1 in env may be a remedy. I'll try to remember to report back.

AprilNEA commented 7 months ago

Add following script in package.json

"scripts": {
    "eas-build-pre-install": "brew remove vips",
    // ...rest
}
joekendal commented 5 months ago

Add following script in package.json

"scripts": {
    "eas-build-pre-install": "brew remove vips",
    // ...rest
}

for conditional based on platform (ignores step if android)

"scrips": {
    "eas-build-pre-install": "if [[ \"$EAS_BUILD_PLATFORM\" == \"ios\" ]]; then brew remove vips; fi",
}