Skip to content

[eas-cli] Say why reading the app config failed - #4354

Open
LizunovSergey wants to merge 3 commits into
expo:mainfrom
LizunovSergey:fix/expo-config-spawn-error
Open

LizunovSergey wants to merge 3 commits into
expo:mainfrom
LizunovSergey:fix/expo-config-spawn-error

Conversation

@LizunovSergey

Copy link
Copy Markdown

Why

Fixes #4213.

Reading the app config shells out to the versioned Expo CLI, and when that exits non-zero the rejected spawn carries only:

/Users/brent/code/mac-migration/node_modules/expo/bin/cli config --json exited with non-zero code: 1
    Error: update:configure command failed.

The child's stderr holds the actual reason and is thrown away, so the user is left with an exit code and a path. In the reported case the cause was dependencies that were missing or half-installed — the CLI had almost certainly printed Cannot find module …, and none of it reached the surface.

Worth noting where the existing guards stop: isExpoInstalled already returns false when expo/bin/cli cannot be resolved at all, and spawnExpoCommand already turns a MODULE_NOT_FOUND on that resolution into a good message. Neither covers this case, because here expo/bin/cli does resolve — it just fails to run.

How

Wrap the spawnExpoCommand call and build a message from what the child actually said:

  • Always include the CLI's stderr, when there is any.
  • Add a dependency hint when the stderr points at unresolved modules (Cannot find module / MODULE_NOT_FOUND), or when the project has no node_modules directory at all — the second covers a CLI that fails before it can print anything useful.
  • Say nothing about dependencies when they are installed and the failure is unrelated, so an app-config error is not misattributed.

This is the same treatment expoUpdatesCommandAsync already gives the expo-updates CLI in utils/expoUpdatesCli.ts, which reads e.stderr and rethrows it rather than letting the bare exit code escape.

Before:

/app/node_modules/expo/bin/cli config --json exited with non-zero code: 1

After:

Failed to read the app config from the Expo CLI.

Error: Cannot find module 'expo-updates'

The project dependencies look missing or incomplete. Install them and run this command again.

Test Plan

Four tests added to src/project/__tests__/expoConfig.test.ts, which previously covered only createOrModifyExpoConfigAsync.

yarn jest src/project/__tests__/expoConfig.test.ts
Tests:       7 passed, 7 total

Whole package, to check nothing else depended on the old behaviour:

yarn jest
Test Suites: 305 passed, 305 total
Tests:       4 skipped, 2662 passed, 2666 total

Each new test was checked against a mutant rather than assumed to discriminate:

mutant failing test
stderr no longer appended surfaces the stderr of a failed expo config command
Cannot find module / MODULE_NOT_FOUND check removed points at the dependencies when the expo config command cannot resolve a module
node_modules existence check inverted points at the dependencies when node_modules is absent… and does not blame the dependencies…
hint added unconditionally does not blame the dependencies when they are installed and the failure is unrelated

Removing the node_modules check outright is not expressible: it is the only use of projectDir, so the compiler rejects it with TS6133 before any test runs.

yarn typecheck, yarn lint (0 warnings, 0 errors) and yarn fmt:check are clean on this branch.

One note in the interest of not overclaiming: on the first full-suite run src/vcs/clients/__tests__/git.test.ts failed. It passes on a clean main tree, passes twice in isolation with this branch applied, and passes on a repeat full run — it does real git work in temp directories and looks parallelism-sensitive, not related to this change.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown

Subscribed to pull request

File Patterns Mentions
packages/eas-cli/** @douglowder

Generated by CodeMention

Warning: The preamble and epilogue options in commentConfiguration are deprecated. Use template instead.

@LizunovSergey

Copy link
Copy Markdown
Author

Adding a before/after against the reported scenario, since the unit tests only prove the new code runs — not that it changes what @brentvatne actually saw.

Fixture: a project whose expo package resolves (so isExpoInstalled is true and the versioned CLI path is taken) but whose CLI exits non-zero the way a half-installed tree does.

cfgfix/package.json                    { "dependencies": { "expo": "*" } }
cfgfix/node_modules/expo/bin/cli       #!/usr/bin/env node
                                       console.error("Error: Cannot find module 'expo-updates'");
                                       process.exit(1);

Then calling getPrivateExpoConfigAsync(dir) from the built output — that is the function update:configure reaches, via privateProjectConfig → OptionalPrivateProjectConfigContextField → getPrivateExpoConfigAsync.

Before, on main @ 24a65ad8:

/…/cfgfix/node_modules/expo/bin/cli config --json exited with non-zero code: 1

which is the message from the issue, with the CLI's own output nowhere in it.

After, on this branch:

Failed to read the app config from the Expo CLI.

Error: Cannot find module 'expo-updates'

The project dependencies look missing or incomplete. Install them and run this command again.

Same fixture, same call, both builds produced by yarn build — the only difference is this branch.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new error wrapping currently drops the underlying error cause/stack and can hide the original spawn error message when stderr is empty, reducing debuggability and actionable context in some failure modes.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Improves EAS CLI’s error reporting when reading the app config via the versioned Expo CLI fails, so users see the underlying reason (especially for missing/incomplete dependencies) instead of only a non-zero exit code.

Changes:

  • Wrap the spawnExpoCommand(['config', '--json', ...]) call to surface the child process stderr and optionally add a “missing/incomplete dependencies” hint.
  • Add Jest coverage for error-message shaping behavior in getPrivateExpoConfigAsync.
  • Add a changelog entry documenting the improved error reporting.
File summaries
File Description
packages/eas-cli/src/project/expoConfig.ts Wraps Expo CLI config read failures with a richer message derived from stderr + dependency heuristics.
packages/eas-cli/src/project/tests/expoConfig.test.ts Adds tests covering stderr surfacing and dependency-hint conditions.
CHANGELOG.md Documents the user-visible behavior change.
Review details

Suppressed comments (1)

packages/eas-cli/src/project/expoConfig.ts:102

  • If the Expo CLI fails without writing anything to stderr (and node_modules exists), this currently throws a generic message and hides the original spawn error (which at least includes the command + exit code). Consider falling back to the original error.message when stderr is empty so users still have actionable context.
  const stderr = typeof error?.stderr === 'string' ? error.stderr.trim() : '';
  const parts = ['Failed to read the app config from the Expo CLI.'];
  if (stderr) {
    parts.push(stderr);
  }
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@douglowder douglowder added the ai-review Commits pushed to PRs with this label be automatically reviewed. label Sep 18, 2026
@LizunovSergey

Copy link
Copy Markdown
Author

Thanks for the approval. The red Test with Node 20 is not from this branch — it is the EasCommand-test.ts timeout that main fixed in #4381, about seven hours after this head was pushed.

The failure is identical on both attempts of run 34507370830:

FAIL src/commandUtils/__tests__/EasCommand-test.ts (62.7 s)
  ● EasCommand › without exceptions › ensures the user data is read
    thrown: "Exceeded timeout of 60000 ms for a test."

Node 22 and Node 24 pass on the same commit. Only the Node 20.18.3 leg fails, and in test.yml that is the coverage: true leg — the one where the old suite's bare TestEasCommand.run() makes oclif Config.load() discover every command in the package, under instrumentation.

e2e8cd245 ("[eas-cli] improve EasCommand test reliability", #4381, 2026-09-11 00:05Z) rewrote exactly that: run() is now handed a pre-built Config that is never loaded, with the note that loading one "takes seconds under coverage with a cold transform cache and has timed out on slow CI runners". This head is 667e252e from 2026-09-10 17:17Z, so the branch predates the fix and still carries the old suite. src/project/__tests__/expoConfig.test.ts, the suite this PR adds to, passes in the same run.

I have deliberately not pushed a merge from main to clear it: the PR reads MERGEABLE / UNSTABLE, so the check is not blocking, and a push would dismiss your approval for what is only someone else's test fix. Say the word if you would rather see it green first and I will merge main in and re-request review.

When the versioned Expo CLI exits non-zero, the rejected spawn carries only
"…/node_modules/expo/bin/cli config --json exited with non-zero code: 1". The
CLI's own stderr — which holds the actual reason — is dropped, so the caller is
left with an exit code and a path.

Surface that output, and when it points at unresolved modules, or the project
has no node_modules at all, say that the dependencies look incomplete. This is
the same treatment `expoUpdatesCommandAsync` already gives the expo-updates CLI.
The rewritten message is what the user needs, but dropping the rejection
threw away its stack and the stdout/stderr/status the spawn attached, so
a log or a debugger had less to work with than before. Passing the
original through the Error `cause` option keeps both, matching how the
rest of the CLI rethrows (`environments/variables.ts`,
`commandUtils/workflow/inputs.ts`, `project/ios/entitlements.ts`).
@LizunovSergey
LizunovSergey force-pushed the fix/expo-config-spawn-error branch from 667e252 to f77a41a Compare November 2, 2026 20:42
@LizunovSergey

Copy link
Copy Markdown
Author

eas-cli moved to changesets (#4580), so I reverted the CHANGELOG.md edit and added .changeset/expo-config-spawn-error.md (eas-cli: patch) with the same summary, and rebased onto current main. The code is byte-identical to the version you approved, @douglowder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Commits pushed to PRs with this label be automatically reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle missing node_modules better

3 participants