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(gatsby-cli): normalize case of windows drive letter #20437

Merged
merged 4 commits into from
Jan 14, 2020

Conversation

vladar
Copy link
Contributor

@vladar vladar commented Jan 6, 2020

Description

This PR ensures that the current working directory on Windows always has an uppercase drive letter (i.e., C: vs. c:).

Motivation

Different utils like "true-case-path", "normalize-path", "slash" treat Windows drive letter differently. "true-case-path" will uppercase, others usually don't care. As a result path normalization produces different results depending on current cwd (c: vs. C:) which manifests in weird issues that are very hard to debug (see related issues bellow).

Ad-hoc fixes like the one introduced in #17492 address the part of the problem but anytime you want to compare a path that is normalized this way you must remember about it and normalize the other side of the comparison the same way.

This is not maintainable (and is especially annoying for those who do not use Windows as they cannot even test it). Things get even worse because we can't really control community plugins or site code but everything should still be working even with a different set of libraries.

This PR is meant to be a general solution to this problem and (hopefully) fix it for good.

Documentation

N/A (as this is a bugfix)

Related Issues

Profiscience/true-case-path#3
#16721
#17811
Fixes #19863

@vladar vladar requested a review from a team as a code owner January 6, 2020 18:11
@vladar vladar requested a review from wardpeet January 6, 2020 18:12
@vladar
Copy link
Contributor Author

vladar commented Jan 6, 2020

@wardpeet Mind reviewing? As you are my companion in the misfortune of using Windows 😃

blainekasten
blainekasten previously approved these changes Jan 6, 2020
Copy link
Contributor

@blainekasten blainekasten left a comment

Choose a reason for hiding this comment

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

This is solid!

@wardpeet
Copy link
Contributor

wardpeet commented Jan 7, 2020

How do I test this?

@vladar
Copy link
Contributor Author

vladar commented Jan 7, 2020

@wardpeet Switch to lowercase c: in cmd/cmder and run default blog starter (without this PR it should produce the error described in #19863)

There is also another repo: https://github.com/murnana/gatsby-bug-repo/tree/feature/gatsbyjs%2319863 which produces webpack warnings on gatsby develop

Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

Some small nitpicks but this is cool! 😎 Great work

packages/gatsby-cli/src/util/normalize-windows-cwd.js Outdated Show resolved Hide resolved
packages/gatsby-cli/src/util/normalize-windows-cwd.js Outdated Show resolved Hide resolved
packages/gatsby-cli/src/util/normalize-windows-cwd.js Outdated Show resolved Hide resolved
@vladar vladar requested a review from wardpeet January 14, 2020 12:19
Copy link
Contributor

@wardpeet wardpeet left a comment

Choose a reason for hiding this comment

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

Looks good to me! :) thanks @vladar

@wardpeet wardpeet merged commit 3e9bf07 into master Jan 14, 2020
@wardpeet wardpeet deleted the vladar/gh-19863 branch January 14, 2020 13:53
@vladar
Copy link
Contributor Author

vladar commented Jan 15, 2020

Published in gatsby-cli@2.8.27

@joshdrumz
Copy link

Hi, I hate to comment on a PR that already fixed this issue #19863 but I'm still getting that error.
I previously had the latest version of gatsby-cli installed and I downgraded to gatsby-cli@2.8.27 and I still get this error.

If there's anything I'm missing here please let me know and thank you in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants