Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Git Bash fails running scriptlet ng-dev #46858

Closed
jayvdb opened this issue Jul 16, 2022 · 8 comments
Closed

Windows Git Bash fails running scriptlet ng-dev #46858

jayvdb opened this issue Jul 16, 2022 · 8 comments
Assignees
Labels
area: dev-infra Issues related to Angular's own dev infra (build, test, CI, releasing) P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent state: has PR
Milestone

Comments

@jayvdb
Copy link
Contributor

jayvdb commented Jul 16, 2022

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

63396a1 (less than a month ago) appears to have broken the ng-dev command on Git for Windows Bash. Occurs here and the components repo.

If I replace TS_NODE_PROJECT=$PWD/.ng-dev/tsconfig.json with TS_NODE_PROJECT=.ng-dev/tsconfig.json, it works.

Presumably $PWD is a full path provided by MSYS, but probably using /c/directory/etc style slashes, and something is rewriting it and adding C:\ in front, because ts-node is attempting to open C:\c\Projects\ng\angular\.ng-dev\tsconfig.json

Note there is no nodejs in the msys/mingw package collection any more: msys2/MINGW-packages#6237
And https://github.com/kentcdodds/cross-env repo has been archived, so this path handling problem cant be solved there kentcdodds/cross-env#257

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

MINGW64 /c/Projects/ng/angular (main) $ yarn -s ng-dev format changed
C:\Projects\ng\angular\node_modules\ts-node\src\index.ts:843
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError:  Unable to compile TypeScript:
error TS5083: Cannot read file 'C:\c\Projects\ng\angular\.ng-dev\tsconfig.json'.

    at createTSError (C:\Projects\ng\angular\node_modules\ts-node\src\index.ts:843:12)
    at reportTSError (C:\Projects\ng\angular\node_modules\ts-node\src\index.ts:847:19)
    at createFromPreloadedConfig (C:\Projects\ng\angular\node_modules\ts-node\src\index.ts:858:36)
    at create (C:\Projects\ng\angular\node_modules\ts-node\src\index.ts:613:10)
    at register (C:\Projects\ng\angular\node_modules\ts-node\src\index.ts:580:15)
    at Object.registerAndCreateEsmHooks (C:\Projects\ng\angular\node_modules\ts-node\src\esm.ts:116:34)
    at file:///C:/Projects/ng/angular/node_modules/ts-node/esm.mjs:8:7
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:385:24) {
  diagnosticCodes: [ 5083 ]
}

Please provide the environment you discovered this bug in (run ng version)

Node: 16.16.0 (from Choco package node-lts)
Yarn: 1.22.17 (from Choco)
Git for Windows 2.37.1 (from Choco)

Anything else?

No response

jayvdb added a commit to jayvdb/angular that referenced this issue Jul 16, 2022
jayvdb added a commit to jayvdb/angular that referenced this issue Jul 16, 2022
Git for Windows $PWD causes the path to tsconfig.json
to be prefixed with the drive letter twice like C:\c\

Fixes angular#46858
@devversion
Copy link
Member

devversion commented Jul 16, 2022

As stated in the PR, this is a temporary solution, we are working with ts-node to fix this (the initial fix PR landed there already).

@devversion
Copy link
Member

I'm confused why the path is ending up like this for you. We specifically tested with Git Bash before we applied this temporary trick.

@jayvdb
Copy link
Contributor Author

jayvdb commented Jul 16, 2022

As this was a "probably" in my assessment above, I added https://www.npmjs.com/package/@bahmutov/print-env , and ran print-env PWD

PWD=/c/Projects/ng/angular

Running cross-env FOO=$PWD node node_modules/@bahmutov/print-env/bin/print-env.js FOO also works as expected

FOO=/c/Projects/ng/angular

So something after the cross-env is doing the msys->DOS file path translation.

@devversion
Copy link
Member

Interesting. If I run this on the components repo, with my Windows machine, it seems to work as expected. If I set an incorrect path for the tsconfig, I can see that the path is converted properly:

image

and

$ echo $PWD
/c/Users/paul/projects/material2

@jayvdb
Copy link
Contributor Author

jayvdb commented Jul 17, 2022

I ran ts-node's test suite on the same environment - no errors.

I'll try all this under C:\Users\.. in case that is relevant. (updated: Same result.)

Which git bash version are you using?

@pkozlowski-opensource pkozlowski-opensource added the area: dev-infra Issues related to Angular's own dev infra (build, test, CI, releasing) label Jul 17, 2022
@ngbot ngbot bot added this to the needsTriage milestone Jul 17, 2022
@alxhub alxhub added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Nov 16, 2022
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Nov 16, 2022
@kiran-pathe
Copy link

Also not working for me on windows.
Can't we switch back to last working version of ts-node ?

image

@devversion
Copy link
Member

We actually should be able to. I have landed a fix on their repository. I don't know if it's released though yet..

devversion added a commit to devversion/angular that referenced this issue Mar 2, 2023
In the past, `ts-node` had a bug that prevented forking processes
when used in combination with `--esm`.

We contributed a fix upstream to `ts-node` to fix this, and this
commit updates to the latest version so that we can simplify our
`ng-dev` invocation.

TypeStrong/ts-node@32d07e2

Fixes angular#46858
@devversion devversion self-assigned this Mar 2, 2023
jessicajaniuk pushed a commit that referenced this issue Mar 2, 2023
In the past, `ts-node` had a bug that prevented forking processes
when used in combination with `--esm`.

We contributed a fix upstream to `ts-node` to fix this, and this
commit updates to the latest version so that we can simplify our
`ng-dev` invocation.

TypeStrong/ts-node@32d07e2

Fixes #46858

PR Close #49289
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: dev-infra Issues related to Angular's own dev infra (build, test, CI, releasing) P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent state: has PR
Projects
None yet
6 participants
@jayvdb @pkozlowski-opensource @alxhub @kiran-pathe @devversion and others