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

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

Closed
garrettg123 opened this issue Feb 28, 2023 · 7 comments
Closed

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

garrettg123 opened this issue Feb 28, 2023 · 7 comments
Labels
needs review Issue is ready to be reviewed by a maintainer

Comments

@garrettg123
Copy link

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 [email protected]
[stderr] 
gyp info using [email protected] | 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
@garrettg123 garrettg123 added the needs review Issue is ready to be reviewed by a maintainer label Feb 28, 2023
@wkozyra95
Copy link
Contributor

wkozyra95 commented Feb 28, 2023

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
Copy link

mikealche commented Apr 18, 2023

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
Copy link

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

@egecavusoglu
Copy link

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

  • Either remove sharp from your dependencies right before you start building your expo project. (hacky workaround)
  • or package sharp as a prebuilt package to it's not built in yarn install. (also a hacky workaround)

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
Copy link

Nantris commented Jan 20, 2024

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
Copy link

Add following script in package.json

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

@joekendal
Copy link

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",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Issue is ready to be reviewed by a maintainer
Projects
None yet
Development

No branches or pull requests

8 participants