EAS build command error because app requires cmake to build

Running "yarn install" in the root dir of your repository 
yarn install v1.22.17
[stderr] warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[stderr] warning " > @firebase/auth@0.19.4" has unmet peer dependency "@firebase/app@0.x".
[stderr] warning " > @firebase/firestore@3.4.1" has unmet peer dependency "@firebase/app@0.x".
[stderr] warning " > @ja-ka/react-native-fade-in-flatlist@1.0.7" has incorrect peer dependency "react@^17.0.2".
[stderr] warning " > @tensorflow-models/pose-detection@0.0.6" has incorrect peer dependency "@mediapipe/pose@~0.4.0".
[stderr] warning " > @tensorflow/tfjs-backend-webgl@3.13.0" has incorrect peer dependency "@tensorflow/tfjs-core@3.13.0".
[stderr] warning "@tensorflow/tfjs-backend-webgl > @tensorflow/tfjs-backend-cpu@3.13.0" has incorrect peer dependency "@tensorflow/tfjs-core@3.13.0".
[stderr] warning " > @tensorflow/tfjs-react-native@0.8.0" has unmet peer dependency "@tensorflow/tfjs-backend-cpu@~3.11.0".
[stderr] warning " > @tensorflow/tfjs-react-native@0.8.0" has incorrect peer dependency "@tensorflow/tfjs-backend-webgl@~3.11.0".
[stderr] warning " > @tensorflow/tfjs-react-native@0.8.0" has incorrect peer dependency "@tensorflow/tfjs-core@~3.11.0".
[stderr] warning " > @tensorflow/tfjs-react-native@0.8.0" has unmet peer dependency "expo-asset@^7.0.0".
[stderr] warning " > @tensorflow/tfjs-react-native@0.8.0" has incorrect peer dependency "expo-camera@^7.0.0".
[stderr] warning " > @tensorflow/tfjs-react-native@0.8.0" has incorrect peer dependency "expo-gl@^7.0.0".
[stderr] warning " > @tensorflow/tfjs-react-native@0.8.0" has incorrect peer dependency "react@^16.12.0".
[stderr] warning " > babel-loader@8.2.3" has unmet peer dependency "webpack@>=2".
[stderr] warning "expo-camera > @koale/useworker@4.0.2" has incorrect peer dependency "react@^16.8.0".
[stderr] warning "firebase-admin > @firebase/database-compat@0.1.4" has unmet peer dependency "@firebase/app-compat@0.x".
[stderr] warning " > flatlist-intro-animations@1.3.4" has incorrect peer dependency "react@~17.0.2".
[stderr] warning " > flatlist-intro-animations@1.3.4" has incorrect peer dependency "react-dom@~17.0.2".
[stderr] warning " > flatlist-intro-animations@1.3.4" has incorrect peer dependency "react-native@https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz".
[stderr] warning "react-native > react-native-codegen > jscodeshift@0.11.0" has unmet peer dependency "@babel/preset-env@^7.1.6".
[stderr] warning " > react-native-animated-flatlist@0.0.3" has unmet peer dependency "lodash@*".
[stderr] warning " > react-native-cardview@2.0.5" has incorrect peer dependency "react-native@^0.56.0".
[stderr] warning " > react-native-elements@3.4.2" has unmet peer dependency "react-native-vector-icons@>7.0.0".
[stderr] warning " > react-native-gifted-chat@0.16.3" has unmet peer dependency "dayjs@*".
[stderr] warning " > react-native-paper@4.11.1" has unmet peer dependency "react-native-vector-icons@*".
[stderr] warning " > react-native-qrcode-scanner@1.5.5" has unmet peer dependency "react-native-camera@>=1.0.2".
[4/4] Building fresh packages...
[stderr] error /home/expo/workingdir/build/node_modules/opencv-build: Command failed.
[stderr] Exit code: 1
[stderr] Command: node ./install.js
[stderr] Arguments: 
[stderr] Directory: /home/expo/workingdir/build/node_modules/opencv-build
[stderr] Output:
[stderr] info install if you want to use an own OpenCV installation set OPENCV4NODEJS_DISABLE_AUTOBUILD
[stderr] info readAutoBuildFile file does not exists: /home/expo/workingdir/build/node_modules/opencv-build/opencv/auto-build.json /home/expo/workingdir/build/node_modules/opencv-build/opencv/auto-build.json
[stderr] info install failed to find auto-build.json: /home/expo/workingdir/build/node_modules/opencv-build/opencv/auto-build.json
[stderr] info install 
[stderr] info install running install script...
[stderr] info install 
[stderr] info install opencv version: 3.4.6
[stderr] info install with opencv contrib: yes
[stderr] info install custom build flags: 
[stderr] info install 
[stderr] info install executing: git --version
[stderr] info install git --version: git version 2.17.1
[stderr] info install 
[stderr] info install executing: cmake --version
[stderr] ERR! Error: failed to execute cmake --version, cmake is required to build opencv, error is: Error: Command failed: cmake --version
[stderr] /bin/sh: 1: cmake: not found
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
yarn exited with non-zero code: 1

My application uses Movenet to detect poses with Tensorflow, which requires OpenCV to be built using CMake, but there seems to be no CMake in EAS Build’s environment. Is there a way around this? Thanks in advance.

Hi @kritt2548

Try using a build lifecycle hook to install cmake using either apt-get install --yes cmake or HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake depending on the EAS_BUILD_PLATFORM

You’ll need to do it in eas-build-pre-install so that it’s available before the JavaScript dependencies are installed.

You seem to have both yarn.lock and package-lock.json.
yarn.lock is generated/updated when you use yarn to manage your depenendencies
package-lock.json is generated/updated when you use npm to manage your dependencies.
You should decide whether you want to use yarn or npm and then delete the lock file corresponding to the other tool.

1 Like

Hello @wodin. I had the same problem related to the build lifecycle hook and did as you mentioned, by adding the script to my package.json:
"eas-build-pre-install": "./pre-install"

and by creating the file pre-install like this:


if [[ "$EAS_BUILD_PLATFORM" == "android" ]]; then
  echo "apt-get install --yes cmake"
elif [[ "$EAS_BUILD_PLATFORM" == "ios" ]]; then
  echo "HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake"
fi

Then I got the error in EAS Build:

Script 'eas-build-pre-install' is present in package.json, running it...
yarn run v1.22.17
$ ./pre-install
[stderr] 
/bin/sh: 1: ./pre-install: Permission denied
[stderr] 
error Command failed with exit code 126.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
yarn exited with non-zero code: 126

What should I do in this case?

Hi @frederiko.famobi

The error shows that your “pre-install” script is not executable.

If you’re on macOS or Linux you should be able to change the mode:

chmod 755 pre-install

and then commit the change.

On Windows you apparently have to do something like this:

git update-index --chmod=+x pre-install

and then commit the change.

Alternatively you should be able to do this:

 "eas-build-pre-install": "bash ./pre-install"

Note that the pre-install file must have Unix end of line characters and not DOS/Windows end of line characters. Also, the first line should be as follows:

#!/bin/bash

(If that fails, try #!/usr/bin/env bash)

1 Like

Hello @wodin

Thank you for the help!

Indeed I forgot to do the chmod 755 pre-install.

I got it working and here’s my final script “pre-install”:

#!/usr/bin/env bash

if [[ "$EAS_BUILD_PLATFORM" == "android" ]]; then
  sudo apt-get install --yes cmake
elif [[ "$EAS_BUILD_PLATFORM" == "ios" ]]; then
  HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake
fi

And on package.json:

 "scripts": {
    "eas-build-pre-install": "./pre-install",
...

In my previous example, the “echo” was incorrect. :sweat_smile:
And now, on EAS Build, everything works fine.

1 Like