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

fix: resolve real path for case insensitive systems #4935

Merged
merged 4 commits into from Jun 26, 2022

Conversation

mdogadailo
Copy link
Contributor

For case insensitive systems (Windows) findWorkspaceDir will return the path to the module as it was called (because of cwd) not the real path.

It leads to an issue when getImporters can't find the the manifest (#4904).

Can be reproduces if pnpm was called from "c:\code\project" but the real path is "C:\Code\Project".
getImporters will find all manifestsByPath as "C:\Code\Project...", but prefixes will use workspace root "c:\code\project...", and it can't match them.

It is possible to try true-case-path but has some vulnerable deps.

@mdogadailo mdogadailo requested a review from zkochan as a code owner June 25, 2022 23:32
@welcome
Copy link

welcome bot commented Jun 25, 2022

💖 Thanks for opening this pull request! 💖
Please be patient and we will get back to you as soon as we can.


async function getRealPath (path: string) {
return new Promise<string>((resolve) => {
fs.realpath.native(path, function (err, resolvedPath) {
Copy link
Member

Choose a reason for hiding this comment

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

Why shoud fs.realpath.native be used instead of fs.realpath?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fs.realpath.native return the actual casing of a path as it is on disk https://github.com/nodejs/node/pull/15776/files#diff-05bc37150ff4e7aa51dc7a28c71164a9e715f45e323ac9a5c67e061821aad3d2R8, fs.realpath is resolving .., . and sym links

Copy link
Member

@zkochan zkochan Jun 26, 2022

Choose a reason for hiding this comment

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

in that case it is better to add a comment about it because in the Node.js docs this information is not present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zkochan I've added comments on getRealPath

@mdogadailo
Copy link
Contributor Author

mdogadailo commented Jun 26, 2022

@zkochan I fixed test for case-sensitive system. I skipped them, because it is not possible to open the path process.cwd().toUpperCase()

@mdogadailo mdogadailo force-pushed the bugfix/fwd-case-insensitive-systems branch from e58ccd4 to c5e930e Compare June 26, 2022 08:48
@zkochan
Copy link
Member

zkochan commented Jun 26, 2022

Run pnpm changeset in the root of the repository and describe your changes. The resulting files should be committed as they will be used during release.

@zkochan zkochan merged commit 6434a82 into pnpm:main Jun 26, 2022
@welcome
Copy link

welcome bot commented Jun 26, 2022

Congrats on merging your first pull request! 🎉🎉🎉

@renovate renovate bot mentioned this pull request Aug 1, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants