Recent NTFS and Windows implement symlinks:
- NTFS junction point can be used as directory symlink since NTFS 3.0 (Windows 2000) using
linkd
orjunction
tools. - NTFS symbolic link can also be used as symlink (for both file and directory) since Windows Vista using
mklink
tool.
But on Cygwin 1.7 (installed on Windows 7), ln -s
creates a text file.
on Cygwin:
$ ln -s -v target mylink
`mylink' -> `target'
on MinGW (or your favorite editor):
$ cat mylink
!<symlink>ÿþt a r g e t
Is it possible to tell Cygwing to use NTFS junction point or NTFS symbolic link?
other question: Is this available on MinGW?
⸻⸻ Short answer ⸻⸻
Define environment variable:
As pointed out by mwm you may also have to go to the settings or to run bash as Administrator. See the Notes section.
⸻⸻ Long answer ⸻⸻
Default Cygwin symlinks are just regular files
By default Cygwin creates text files as workaround for Windows symlink flaw. These files are not really symlinks. Almost all Windows programs do not considers these files as symlinks.
Native symlinks are available on recent Windows versions
Recent NTFS and Windows implement symlinks:
linkd
orjunction
tools.mklink
tool.Cygwin can create native NTFS symlinks
Simplified extract of the Cygwin documentation:
Configuring Cygwin
Cygwin User's Guide presents variable
CYGWIN
and optionwinsymlinks
:CYGWIN=winsymlinks:native
always creates a link but uses a Cygwin fall-back when target does not exists
on Cygwin:
on MinGW:
People using both Windows and Cygwin programs may have issues when a symlink is created as a dummy file (Cygwin fallback when target is missing)...
CYGWIN=winsymlinks:nativestrict
always uses native-Windows symlink but fails when target does not exist
on Cygwin:
Because
nativestrict
requires the target exists before the symlink creation, some commands/scripts may fail when creating a link.Notes
Since Windows 10 build 14972, native NTFS symlinks are available in a non-elevated shell by enabling the Developer Mode in the Developer Settings. Reference: https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/
In older versions, only administrators have the ability to create native NT symlinks so under Windows UAC, the Cygwin terminal emulator (mintty) should be run with elevated privileges (right-click the shortcut and choose Run as Administrator or set the mintty shortcut property, Advanced → Run as Administrator).
Special thanks to Guria, Spooky and Gene Pavlovsky for their contributions.