Skip to content

fix(migrations): resolve migration failure when tsconfig specifies rootDir#69194

Open
aparzi wants to merge 1 commit into
angular:mainfrom
aparzi:fix-run-migration-devkit
Open

fix(migrations): resolve migration failure when tsconfig specifies rootDir#69194
aparzi wants to merge 1 commit into
angular:mainfrom
aparzi:fix-run-migration-devkit

Conversation

@aparzi

@aparzi aparzi commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

When rootDir was set in a project's tsconfig (e.g. rootDir: "src"), tsurge-based migrations would fail because projectRoot was derived from rootDir, causing rootRelativePath to be computed relative to src/ instead of the workspace root. This produced paths like app/app.ts instead of src/app/app.ts, which the DevKit tree could not resolve.

Fix by overriding info.projectRoot to fs.pwd() (always / in the DevKit filesystem) immediately after program creation, ensuring workspace-relative paths are used for all tree updates.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

Does this PR introduce a breaking change?

  • Yes
  • No

@pullapprove pullapprove Bot requested a review from kirjs June 5, 2026 15:40
@alan-agius4 alan-agius4 requested review from devversion and removed request for kirjs June 5, 2026 16:02
@pullapprove pullapprove Bot requested review from kirjs and removed request for devversion June 5, 2026 16:02
@alan-agius4 alan-agius4 requested a review from devversion June 6, 2026 13:05
@pullapprove pullapprove Bot removed the request for review from devversion June 6, 2026 13:05
…otDir

When `rootDir` was set in a project's tsconfig (e.g. `rootDir: "src"`),
tsurge-based migrations would fail because `projectRoot` was derived from
`rootDir`, causing `rootRelativePath` to be computed relative to `src/`
instead of the workspace root. This produced paths like `app/app.ts`
instead of `src/app/app.ts`, which the DevKit tree could not resolve.

Fix by overriding `info.projectRoot` to `fs.pwd()` (always `/` in the
DevKit filesystem) immediately after program creation, ensuring
workspace-relative paths are used for all tree updates.
@aparzi aparzi force-pushed the fix-run-migration-devkit branch from 2311352 to dfd93a5 Compare June 8, 2026 09:25
@angular-robot angular-robot Bot added the area: migrations Issues related to `ng update`/`ng generate` migrations label Jun 8, 2026
@aparzi aparzi changed the title fix: resolve migration failure when tsconfig specifies rootDir fix(migrations): resolve migration failure when tsconfig specifies rootDir Jun 8, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jun 8, 2026

@alan-agius4 alan-agius4 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.

I briefly synced with @devversion about this, and it’s considered risky, so we’ll need to run some additional verifications.

Furthermore, this approach doesn't support cases where the tsconfig is located outside the root directory, as rootDirs are resolved relative to the tsconfig location and hence using the fw.pwd() doesn't seem correct.

Regardless, did a quick check and potentially the changes should probably be implemented within getProgramInfoFromBaseInfo rather than mutating the info object directly.

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

Labels

area: migrations Issues related to `ng update`/`ng generate` migrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants