EAS build with git submodules

I have a repository which uses git submodules. It is configured corretly, or at least it worked without problems with expo build command, but eas build throws an error in “Run gradlew” phase:

[stderr] Error: @build-script-error-begin
[stderr] Error loading assets JSON from Metro. Ensure you've followed all expo-updates installation steps correctly. Unable to resolve module ./src/common/components/CustomSnackbar from /build/workingdir/build/App.js: 
[stderr] None of these files exist:
[stderr]   * src/common/components/CustomSnackbar(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
[stderr]   * src/common/components/CustomSnackbar/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json)
[stderr]   21 | import AppNavigator from './src/router';
[stderr]   22 | import { navigationRef } from './src/router/RootNavigation';
[stderr] > 23 | import CustomSnackbar from './src/common/components/CustomSnackbar';

It seems the problem is that it cannot see the files in the folder attached with the subrepo ./src/common. I found some docs about monorepos, but I don’t know how I can configure to make it work with subrepos. Thanks for any help!

I don’t think it will work with submodules, the way we upload project to the workers is by

  • git clone --depth=1 path_to_repo
  • create tar of that shallow clone

There might be workaround for that, if you would run git submodule update --init in npm hook. If repo is public it should be easy, if not you can upload ssh key via EAS Secrets.

we might support that directly in the future, but it’s quite niche use case. It worked with expo build because for old builds js bundle was created locally and only that was uploaded to the server but with eas we need to uplaod everything.

Thanks for the clarification! Yes I’ve already tried git submodule update --init --recursive in eas-build-pre-install hook, but it threw a permission error since the repo is private. I didn’t know how to proceed with this issue, or it’s worth it or not, but then I’ll read through the docs about EAS Secrets, and give it a try. I’ll let you know if I have a progress on this.

@geniko did you ever find a work around to this?

if the repos you are trying to access are private you can do the appropriate set up to ensure the build worker has access to the private repos in the eas-build-pre-install hook, eg: set up ssh key

No, unfortunately I didn’t find a solution. I could set the SSH key in pre install hook, but there was another problem. I’m using CI for the build, and Gitlab CI wants the url in .gitmodule file to be relative, but EAS wants it to be absolute, and I was unable to solve this problem.

we are uploading copy of the project created using git clone from local project so the remote origin is pointing to the local path and because of that your relative url is resolved incorrectly. to fix that run

git remote set-url origin git@github.com:example/repo.git

before initializing submodules

I’m not sure I understand 100% what you’re suggesting, so I should set the main repo’s origin url in the pre-install hook before initializing submodules?

yes, info about real remote is lost during packaging, so you need to restore it

If you have any other problems you can check this PR to docs for more info

1 Like