9

I have just started to use msys2. I wanted to make a sym link to a folder on my d:. I can access it like this:

cd /d/mytestfolder/

I tried:

  • When I do ln -s /d/mytestfolder/ testfolder - this seems to be working, but takes a long time, then I realized it just makes a copy and not a link at all :(

  • I also tried cmd /c mklink /c/mytestfolder (found that somewhere on the web)... no joy

  • I even tried (in windows explorer) making a windows short cut. I can see that file, but it does not work with cd.

So how can I make a link/shortcut to to my folder?

4
  • duplicate of http://superuser.com/questions/550732/use-mklink-in-msys
    – matzeri
    Jul 6, 2016 at 9:08
  • @matzeri - hey, that is actually where I got cmd /c 'mklink link target' from.... but that did not work :( Jul 6, 2016 at 9:10
  • mklink is a windows command. It does not understand /c/mytestfolder
    – matzeri
    Jul 6, 2016 at 9:19
  • @matzeri - cool, cmd /c 'mklink link c:\mytestfolder' worked, thanks. You can put that up as an answer if you want... Jul 6, 2016 at 9:28

2 Answers 2

7

Same as Use mklink in msys

reminding that mklink is a windows command, so it does not understand /c/mytestfolder but c:\mytestfolder must be used

cmd /c 'mklink link c:\mytestfolder'
4

In order for MSYS2 to use native Windows symlinks you need to set:

export MSYS=winsymlinks:nativestrict

Then ln -s creates dir or file symlinks:

ln -s $USERPROFILE/tmp ~/tmp

cd ~
cmd /c dir
2022-12-09  01:04    <SYMLINKD>     tmp [C:\Users\user\tmp]

Unfortunately, there is no way you create directory junctions from MSYS2 env.

To avoid stupid Windows security restrictions, you need to enable developer mode:

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"

https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/ Windows 10 Creator Update allows creation of symlinks for apps with privileges non-elevated to admimistrator if Developer Mode is enabled.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .