dotbot icon indicating copy to clipboard operation
dotbot copied to clipboard

Windows symlinks are always recreated

Open kurtmckee opened this issue 3 years ago • 0 comments

On Windows, os.readlink() returns a UNC path that never matches the anticipated symlink destination. This causes dotbot to always recreate the links (example dotbot output below):

Incorrect link ~/.gitconfig -> \\?\C:\Users\Me\Documents\dev\dotfiles\gitconfig

I tested two possible fixes:

  1. Use os.path.realpath() instead of os.readlink()
  2. Conditionally remove the \\?\ prefix when dotbot is running on Windows.

Option 1 results in a unit test failure:

[42/55] (link-relink-relative-leaves-file.bash)
relink relative does not incorrectly relink file
- test failed.
-> fail!

Therefore I recommend going with option 2, which gives expected results (example dotbot output below):

Link exists ~/.gitconfig -> C:\Users\Me\Documents\dev\dotfiles\gitconfig

kurtmckee avatar Apr 11 '22 13:04 kurtmckee