Skip to content

fix(schematics): use a POSIX path for the Cloud Run main.js entry - #3274

Merged
armando-navarro merged 6 commits into
angular:mainfrom
fr-esco:fix-3098
Aug 18, 2026
Merged

fix(schematics): use a POSIX path for the Cloud Run main.js entry#3274
armando-navarro merged 6 commits into
angular:mainfrom
fr-esco:fix-3098

Conversation

@fr-esco

@fr-esco fr-esco commented Oct 7, 2022

Copy link
Copy Markdown
Contributor

Description

Running ng deploy from Windows with the Cloud Run SSR option writes the generated run/package.json entry paths with backslashes ("main": "dist\\my-project\\server\\main.js"), which the Linux-based Cloud Run runtime cannot resolve. This PR builds that path with forward slashes explicitly, since the target runtime is always Linux regardless of the deploying machine.

The branch originally also added shell: true to the deploy runner, fixing spawn gcloud ENOENT on Windows. That half was dropped when the branch was brought current with main:

  • The package-manager commands now route through cross-spawn, which resolves the platform executable on Windows. The gcloud calls still use plain spawn, so the spawn gcloud ENOENT half of spawn gcloud ENOENT #3098 is not fixed by this PR.
  • The deploy hardening work relies on arguments not passing through shell parsing, so reintroducing a shell would undo part of it.

Refs #3098


Original author notes (2022):

Checklist

  • Issue number for this PR: spawn gcloud ENOENT #3098
  • Docs included?: No
  • Test units included?: No
  • In a clean directory, yarn install, yarn test run successfully? Yes

Description

Running the deploy schematic on Windows:

  1. Child processes that need gcloud cannot properly locate it;
  2. The path to main.js is printed escaped by \\ instead of /, even though target runtime is Linux based.

Code sample

N. A.

@davideast davideast left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@fr-esco Thank you so much and our apologies for taking so long to get to it. Since this is an older PR and there are a lot of merging PRs in flight it's going to take a bit to get this tested and merged so hang tight.

@davideast davideast self-assigned this Jun 23, 2023
Resolves the spawnAsync conflict by taking main's side: the runner now
receives command and args separately through cross-spawn, which handles
the Windows executable resolution that shell: true addressed, and a
shell would reintroduce the argument parsing the injection fixes
removed. The main.js path fix carries through unchanged.
@armando-navarro armando-navarro changed the title Fix #3098 fix(schematics): use a POSIX path for the Cloud Run main.js entry Aug 18, 2026
@armando-navarro armando-navarro added bump: patch comp: schematics ng add / deploy schematics (src/schematics). type: bug Defect: expected behavior doesn't happen. labels Aug 18, 2026
@armando-navarro

armando-navarro commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Sorry this sat for so long. I picked this up to land it with your authorship: I merged current main into your branch, and the two halves of your fix went different ways.

  • The main.js path fix carries through unchanged and is the whole diff now. It is still a real bug on today's main.
  • The shell: true half was dropped in the merge. The recent injection hardening moved the package-manager commands to cross-spawn and depends on arguments not being shell-parsed. The gcloud spawns still bypass cross-spawn today, so the ENOENT you originally hit is not fixed by this PR and needs its own follow-up.

@armando-navarro
armando-navarro requested review from tyler-reitz and removed request for tyler-reitz August 18, 2026 05:52
@armando-navarro
armando-navarro merged commit 73acea7 into angular:main Aug 18, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bump: patch comp: schematics ng add / deploy schematics (src/schematics). type: bug Defect: expected behavior doesn't happen.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants