PEZ/rn-rf-shadow

Build failed npm run eas-build-post-install exited with non-zero code: 1

hjer opened this issue · 7 comments

hjer commented

I am trying to build my app for production. It goes well for Android. But when I try to do the same for iOS i get the following message in the "Post-install hook" of the build:

Script 'eas-build-post-install' is present in package.json, running it...

> build@1.0.0 eas-build-post-install

> npx shadow-cljs release app

[stderr] shadow-cljs - config: /Users/expo/workingdir/build/shadow-cljs.edn

[stderr] The operation couldn’t be completed. Unable to locate a Java Runtime.

[stderr] Please visit http://www.java.com for information on installing Java.

[stderr] ===== ERROR =================

[stderr] java process exit with non-zero exit code

[stderr] =============================

npm run eas-build-post-install exited with non-zero code: 1

So the app can not build because Java is not installed in the installation process, which is the point of the 'eas-build-pre-install.sh' file. It seams that the file is recognised - but Java is not installed.

Any ideas on why this is would be highly appreciated!

PEZ commented

Do you have a clue what's going on here, @bpringe?

hjer commented

This is the eas-build-pre-install.sh

#!/usr/bin/env bash

# If the OS is MacOS, install Java so that the shadow-cljs build succeeds
if [[ $OSTYPE == "darwin"* ]]; then
  brew install openjdk@11
  sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
fi
PEZ commented

I'm not familiar with how this is supposed to work. But it's interesting that the Android build works. It should also need Java.

Where are these scripts being run? Some cloud?

hjer commented

Hello again! First of, now I see that the android install is not using the script in the eas-build-pre-install.sh. Since the if statement checks if the os i darwin, i.e apple (and there is a comment saying so, lol).

But I think I know where it goes wrong now. The eas-build-pre-install.sh is called with the "eas-build-pre-install" hook in package.json and the script is running and everything is installed, as compared to first communicated. (the error itself is somewhat devious in this sense, since it shows in the post-install hook)!

However when I check the logs for the "Pre install Hook" I can see the following:

==> Caveats
==> openjdk@11
For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk

openjdk@11 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have openjdk@11 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/openjdk@11/bin:$PATH"' >> ~/.zshrc

For compilers to find openjdk@11 you may need to set:
  export CPPFLAGS="-I/opt/homebrew/opt/openjdk@11/include"

The first part sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk was already implemented in the pre-install script.

So I added the other two and tried again - but I don't think they are running, or at least I cannot see it in the logs. So I'm wondering if any of the commands after the brew install openjdk@11 are running and that is where the problem is.

Please let me know how I can test this theory.

UPDATE:
brew installed
system linked
exporting done
CPPFLAGS done

I added echos after linking the commands using the && operator, in the .sh file. So it seams that the commands are executed - even though it does not show in the logs.

So again, I don't know why things go wrong! :)

Where are these scripts being run? Some cloud?

IIRC these are being run in Expo's servers. They're run during the EAS build process.

I'm not sure what could be going wrong here but I suspect something changed with their iOS build process that caused this to stop working as it used to.

It's been quite some time since I last did anything with Expo. The last time I used it was for a previous job.

hjer commented

Okay! I have some updates, what I did is I changed:
sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
to
sudo ln -sfn /opt/homebrew/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk

Which, when I look at it again, with less stressed eyes, it says right there in the log!

Thank you for you help!