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 Windows developer mode symlinks #13629

Closed
wants to merge 1 commit into from

Conversation

khogeland
Copy link

The OS version check in #13488 breaks the developer mode symlink behavior.

IsWindowsVersionOrGreater does not work as advertised, and returns false on Windows 10 if not called from an executable with an associated application manifest declaring its compatibility for Windows 10. (Very cool, Microsoft.) The other methods of checking OS version are far more verbose and complicated, which doesn't seem warranted here.

As an alternative workaround, this PR replaces the ahead-of-time version check with a retry without the flag if the function reports an invalid argument exception.

@meteorcloudy

@google-cla google-cla bot added the cla: yes label Jun 30, 2021
@@ -467,6 +463,13 @@ int CreateSymlink(const wstring& symlink_name, const wstring& symlink_target,

if (!CreateSymbolicLinkW(name.c_str(), target.c_str(),
symlinkPrivilegeFlag)) {
if (GetLastError() == ERROR_INVALID_PARAMETER) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: This means on older Windows versions with developer mode enabled, each symlink operation triggers CreateSymlinkLink twice, which has some performance implication. But I guess it's small issue which won't impact the vast majority of Windows users.

@meteorcloudy
Copy link
Member

Thanks for the fix!

@bazel-io bazel-io closed this in 33903d2 Jul 2, 2021
katre pushed a commit to katre/bazel that referenced this pull request Jul 13, 2021
The OS version check in bazelbuild#13488 breaks the developer mode symlink behavior.

`IsWindowsVersionOrGreater` does not work as advertised, and returns false on Windows 10 if not called from an executable with an associated application manifest declaring its compatibility for Windows 10. (Very cool, Microsoft.) The other methods of checking OS version are far more verbose and complicated, which doesn't seem warranted here.

As an alternative workaround, this PR replaces the ahead-of-time version check with a retry without the flag if the function reports an invalid argument exception.

@meteorcloudy

Closes bazelbuild#13629.

PiperOrigin-RevId: 382734470
katre pushed a commit to katre/bazel that referenced this pull request Jul 13, 2021
The OS version check in bazelbuild#13488 breaks the developer mode symlink behavior.

`IsWindowsVersionOrGreater` does not work as advertised, and returns false on Windows 10 if not called from an executable with an associated application manifest declaring its compatibility for Windows 10. (Very cool, Microsoft.) The other methods of checking OS version are far more verbose and complicated, which doesn't seem warranted here.

As an alternative workaround, this PR replaces the ahead-of-time version check with a retry without the flag if the function reports an invalid argument exception.

@meteorcloudy

Closes bazelbuild#13629.

PiperOrigin-RevId: 382734470
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants