I stumbled upon this cool Cygwin option that allows you to use native Windows (NTFS) symlinks (like CreateSymbolicLinkW in the
Win32 API, or mklink via cmd shell). Apparently there's a CYGWIN
environment variable that "is used to configure many global settings for
the Cygwin runtime system".
One of those options is winsymlinks:{lnk,native,nativestrict}.
if set to just
winsymlinksorwinsymlinks:lnk, Cygwin creates symlinks as Windows shortcuts with a special header and the R/O attribute set.If set to
winsymlinks:nativeorwinsymlinks:nativestrict, Cygwin creates symlinks as native Windows symlinks on filesystems and OS versions supporting them.The difference between
winsymlinks:nativeandwinsymlinks:nativestrictis this: If the filesystem supports native symlinks and Cygwin fails to create a native symlink for some reason, it will fall back to creating Cygwin default symlinks withwinsymlinks:native, while withwinsymlinks:nativestrictthesymlink(2)system call will immediately fail.For more information on symbolic links, see the section called “Symbolic links”.
So basically, setting the winsymlinks option to nativestrict forces Cygwin to use native symlinks!
Normally, when you make symlinks in Cygwin, it creates plain files containing a magic cookie, followed by the path to which the link points to. You can read up on this in the Cygwin documentation.
But with this option, we can create symlinks using ln and it will create NTFS-style symlinks automatically!
CYGWIN=winsymlinks:nativestrict
ln -sf /source/file /new/pathCool! No need to open cmd and manually symlink my files anymore.
Note: You still need Administrator privileges, or must have the SeCreateSymbolicLinkPrivilege
privilege
for this to work.
Works correctly as i wan't. Thank's!!!