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

Normalize appRootPath to prevent issues on Windows #3028

Closed
wants to merge 1 commit into from
Closed

Normalize appRootPath to prevent issues on Windows #3028

wants to merge 1 commit into from

Conversation

jbjhjm
Copy link

@jbjhjm jbjhjm commented May 18, 2020

workspace/utils/app-root - appRootPath constant was un-normalized until now.
This lead to issues with dep-graph on Windows systems.

Fixes path-based detection #2955

@@ -1,8 +1,11 @@
import { fileExists } from './fileutils';
import * as path from 'path';

// TODO: vsavkin normalize the path
export const appRootPath = pathInner(__dirname);
function normalizeBackslashes(dir) {
Copy link

@georgiee georgiee May 18, 2020

Choose a reason for hiding this comment

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

While looking at this, I think we should stay path delimiter separator agnostic instead of forcing windows into using forward slashes. Otherwise we could run into other issues in unknown places where app-root is being used. Apart from this it's a good start for a discussion. I'm excited to see the CI/CD results if this fixes it or if implications of this change are correctly revealed by the CI/CD.

Let's wait for some maintainer comments. Thank you for crafting this PR 👍

Reference:
https://nodejs.org/api/path.html#path_path_delimiter
https://nodejs.org/api/path.html#path_path_sep

Copy link
Author

Choose a reason for hiding this comment

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

I guess you meant https://nodejs.org/api/path.html#path_path_sep not delimiter. You may be right, let's wait for maintainers feedback.

Choose a reason for hiding this comment

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

Oh yes, I just searched for a path example and cited the wrong section. I wanted to mention the path separator of course. Thanks for pointing out 👍

@georgiee
Copy link

FYI. The CI failed for a formating issue and prevented to run any unit test tests from what I see.
via https://app.circleci.com/pipelines/github/nrwl/nx/1909/workflows/197a0b8e-3316-4d8c-84cc-b3907d06425c/jobs/14691/steps
Screenshot 2020-05-19 at 12 27 59

@georgiee
Copy link

I just found out about prior art by @rhutchison, opened 21 days ago, marked ready 6 days ago
#2941

I see that the requested change inside the app-root export was not addressed for some good reasons ("too risky"). He points out that the impact of changing the appRoot globally for Nx is quite big and changing it in only this place could fix the issue with limited impact. That's a good point. The fix is the same and it's also missing an agnostic approach using the OS path separator.

Would be good to get some guidance here. Can we trust the Nx Test Suite to just try it with your proposal or work on a OS agnostic solution?

At least you provided a solution matching the changes requested by @FrozenPandaz in the other PR.

I think this normalization should happen in https://github.com/nrwl/nx/blob/master/packages/workspace/src/utils/app-root.ts#L4 (as dictated by a todo comment by @vsavkin 😅.)

@FrozenPandaz
Copy link
Collaborator

I merged #2941 which solves the same issue so I'm going to close this PR.

Thank you for your contribution!

@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants