EAS Local Build stopped working again only iOS.

Continuing the discussion from EAS Local Build stopped working:

I had a build that had worked as recently as March 1. With some new code it the EAS portion of the build failed.

I am on Expo 47.

One of the checks we did was to rerun the previous build and we’re getting it to error out.

Just in case we’re missing something because I had locked the version of EAS-CLI to 0.55.1 in my local branch I have installed node 16.19.1 (this ensures I have an empty global packages) I installed the latest yarn (classic) and eas-cli only (no local plugin as @wodin had indicated before). not even expo-cli

eas --version
eas-cli/3.8.1 darwin-x64 node-v16.19.1

This is only failing on the macOS build for iOS but not the Android build that’s running in ubuntu.

Here’s where I think the relevant logs are

[PREBUILD] yarn run v1.22.19
[PREBUILD] $ /private/var/folders/r_/xdpjhyys6pxc3_nj8dltjwhc0000gn/T/eas-build-local-nodejs/86e1280a-3882-4a3c-a7b6-30e2cca8a3b8/build/node_modules/.bin/expo prebuild --no-install --platform ios
[PREBUILD] - Creating native project directories (./ios and ./android) and updating .gitignore
[PREBUILD] Unexpected end of JSON input
[PREBUILD] - Creating native project directories (./ios and ./android) and updating .gitignore
[PREBUILD] ✖ Failed to create the native project.
[PREBUILD] You may want to delete the `./ios` and/or `./android` directories before trying again.
[PREBUILD] Done in 3.18s.
[PREBUILD] Running "yarn install" in the root dir of your repository
[PREBUILD] yarn install v1.22.19
[PREBUILD] [1/4] Resolving packages...
[PREBUILD] success Already up-to-date.
[PREBUILD] $ husky install || true
[PREBUILD] fatal: not a git repository (or any of the parent directories): .git
[PREBUILD] husky - git command not found, skipping install
[PREBUILD] Done in 0.90s.
[INSTALL_PODS]
Error: spawn pod ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
    at onErrorNT (node:internal/child_process:485:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

With DEBUG=* I see it is hitting my private repo proxy

[PREBUILD] $ /private/var/folders/r_/xdpjhyys6pxc3_nj8dltjwhc0000gn/T/eas-build-local-nodejs/87d28345-d20c-4bed-8192-52ce257167b6/build/node_modules/.bin/expo prebuild --no-install --platform ios
[PREBUILD] - Creating native project directories (./ios and ./android) and updating .gitignore
[PREBUILD] 2023-03-16T18:57:17.163Z expo:utils:npm Run: npm view expo-template-bare-minimum@sdk-47 dist.tarball --json
[PREBUILD] 2023-03-16T18:57:17.164Z expo:utils:npm Fetch from URL: https://repo.xxxxx.com/repository/npm/expo-template-bare-minimum/-/expo-template-bare-minimum-47.0.22.tgz
[PREBUILD] 2023-03-16T18:57:17.168Z expo:api:fetch:base fetch: https://repo.xxxxx.com/repository/npm/expo-template-bare-minimum/-/expo-template-bare-minimum-47.0.22.tgz
[PREBUILD] Unexpected end of JSON input

I have verified that I can get data a valid TGZ file using the same credentials and the errors never said 401.

Just running prebuild on its own

❯ DEBUG=* npx expo prebuild --no-install --platform ios
npm WARN config optional Use `--omit=optional` to exclude optional dependencies, or
npm WARN config `--include=optional` to include them.
npm WARN config
npm WARN config     Default value does install optional deps unless otherwise omitted.
- Creating native project directories (./ios and ./android) and updating .gitignore
  expo:utils:npm Run: npm view expo-template-bare-minimum@sdk-47 dist.tarball --json +0ms
  expo:utils:npm Fetch from URL: https://repo.xxxxxx.com/repository/npm/expo-template-bare-minimum/-/expo-template-bare-minimum-47.0.22.tgz +0ms
  expo:api:fetch:base fetch: https://repo.xxxxx.com/repository/npm/expo-template-bare-minimum/-/expo-template-bare-minimum-47.0.22.tgz +0ms
Unexpected end of JSON input
- Creating native project directories (./ios and ./android) and updating .gitignore
✖ Failed to create the native project.
You may want to delete the `./ios` and/or `./android` directories before trying again.

I did another hack of spawnAsync to see the values. Like my previous comment on the long command line on windows I see the JSON base64 encoded as part of the command line.

I decoded the Base64 and discovered that it actually gets cut off thus getting the truncated output.

ore","appName":"xxxxx","appIdentifier":"com.xxxxxx.xxxxx","buildProfile":"production","gitCommitHash":"8d9162d44676f7af8117f1c894ac0afae4007517","gitCommitMessage":"Revert NPM Cache remobal","isGitWorkingTreeDirty":true,"username":"opsexpo","runWithNoWaitFlag":false,"runFromCI":false,"bui%

UPDATE: NVM I missed copying the last = sign

I do notice that the provisioningProfileBase64 is quite long.

Delving a bit further. It seems to be calling my private nexus server with the

Authorization: Bearer {{VALUE OF EXPO_TOKEN}}

Which isn’t what I am expecting… I am expecting the value from .npmrc

Since we know it’s sending the wrong data to the nexus server to get the minimal template. We temprorariiy removed the registry= setting in the project .npmrc, but that’s not ideal as it is pulling deps we don’t control.

I think what should happen is that the retrieval of the minimal template should be done with just npm and not this faked one

When using a custom private npm registry expo preuild sends the EXPO_TOKEN value as the authorization · Issue #21740 · expo/expo (github.com)

Another temporary work around I did was allow anonymous access to just the templates folder

  expo-minimal-template:
    # This service is to workaround for https://github.com/expo/expo/issues/21740
    # This will route to npmjs for only this path
    image: openrelay/proxypass
    environment:
      PROXY_TARGET: https://registry.npmjs.com
    networks:
      - traefik
    deploy:
      placement:
        constraints:
          - node.role != manager
      replicas: 2
      labels:
        - "traefik.enable=true"
        - "traefik.docker.network=traefik"
        - "traefik.main.frontend.rule=Host:repo.xxxxx.com; Method: GET; PathPrefix:/repository/npm/expo-template-bare-minimum; ReplacePathRegex: ^/repository/npm/(.*) /$$1"
        - "traefik.main.port=80"