WSL: Symbolic Links With Terminating Slash Don't Function Properly

Brief Description: I was trying to create a symbolic link to a specific directory on the Windows mount to my home dir for convenience. I did this using auto complete with a TAB (which added a terminating slash). Then I quickly discovered that the symbolic link created was only ever returning the dir that was directly linked to (never anything deeper - even if specify an invalid path). I fixed this by creating the link without the terminating slash, and that worked fine. However, I still wanted to report the problem in case it helps in some other context, or just so others know about this odd behavior. See commands below to see what I mean.

Windows build number: 14388.0

Commands to Reproduce the Error:

rcardillo@LAPDOG:~$ ln -s /mnt/c/WORK_REPO/ ~/WORK_REPO
rcardillo@LAPDOG:~$ ls -al ~/WORK_REPO
lrwxrwxrwx 1 rcardillo rcardillo 17 Jul 13 01:20 /home/rcardillo/WORK_REPO -> /mnt/c/WORK_REPO/
rcardillo@LAPDOG:~$ ls -al /mnt/c/WORK_REPO/github/
total 4
drwxrwxrwx 2 root root 0 Jul 13 00:56 .
drwxrwxrwx 2 root root 0 Jul 13 00:32 ..
rcardillo@LAPDOG:~$ ls -al ~/WORK_REPO/github/
total 44
drwxrwxrwx 2 root root 0 Jul 13 00:32 .
drwxrwxrwx 2 root root 0 Jul 13 00:32 ..
drwxrwxrwx 2 root root 0 Jul 13 00:32 angular-1.3.5
drwxrwxrwx 2 root root 0 Jul 13 00:32 angular-1.3.5.zip
drwxrwxrwx 2 root root 0 Jul 13 00:32 bootstrap-3.3.1-dist
drwxrwxrwx 2 root root 0 Jul 13 00:32 github
drwxrwxrwx 2 root root 0 Jul 13 00:32 MediaHelpers
rcardillo@LAPDOG:~$ ls -al ~/WORK_REPO/github/any/thing/else
total 44
drwxrwxrwx 2 root root 0 Jul 13 00:32 .
drwxrwxrwx 2 root root 0 Jul 13 00:32 ..
drwxrwxrwx 2 root root 0 Jul 13 00:32 angular-1.3.5
drwxrwxrwx 2 root root 0 Jul 13 00:32 angular-1.3.5.zip
drwxrwxrwx 2 root root 0 Jul 13 00:32 bootstrap-3.3.1-dist
drwxrwxrwx 2 root root 0 Jul 13 00:32 github
drwxrwxrwx 2 root root 0 Jul 13 00:32 MediaHelpers
rcardillo@LAPDOG:~$

Notice how in the first command, I demonstrate that the github directory is actually empty, but when I use the symbolic link, it returns the contents of the directory that the link points to. Likewise, event when I specify an invalid path, it will always return the contents of the directory the link points to.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 23 (8 by maintainers)

Most upvoted comments

Thanks for reporting this issue, this issue has been fixed internally and will be in a future flight.

Doh! @onomatopellan, you are correct. When testing I ran ln -s /mnt/c/tmp ~/temp instead of ln -s /mnt/c/tmp/ ~/temp. Forgot the all important ‘/’ at the end of tmp. Output between the two on 14901:

russ@DESKTOP-K1JHN54:~$ ln -s /mnt/c/tmp ~/temp
russ@DESKTOP-K1JHN54:~$ ll temp
lrwxrwxrwx 1 russ russ 10 Aug 12 12:02 temp -> /mnt/c/tmp/
russ@DESKTOP-K1JHN54:~$ ll temp/foo
total 4
drwxrwxrwx 2 root root 0 Aug 12 12:01 ./
drwxrwxrwx 2 root root 0 Aug 12 12:01 ../
-rwxrwxrwx 1 root root 0 Aug 12 12:01 bar.txt*
drwxrwxrwx 2 root root 0 Aug 12 12:01 baz/
-rwxrwxrwx 1 root root 0 Aug 12 12:01 foo.txt*
russ@DESKTOP-K1JHN54:~$ ll temp/foo/baz
total 0
drwxrwxrwx 2 root root 0 Aug 12 12:01 ./
drwxrwxrwx 2 root root 0 Aug 12 12:01 ../
-rwxrwxrwx 1 root root 0 Aug 12 12:01 baz.txt*
russ@DESKTOP-K1JHN54:~$ rm temp
russ@DESKTOP-K1JHN54:~$ ln -s /mnt/c/tmp/ ~/temp
russ@DESKTOP-K1JHN54:~$ ll temp
lrwxrwxrwx 1 russ russ 11 Aug 12 12:02 temp -> /mnt/c/tmp//
russ@DESKTOP-K1JHN54:~$ ll temp/foo
total 12
drwxrwxrwx 2 root root 0 Aug 12 12:01 ./
drwxrwxrwx 2 root root 0 Aug 12 12:01 ../
drwxrwxrwx 2 root root 0 Aug 12 12:01 foo/
russ@DESKTOP-K1JHN54:~$ ll temp/foo/baz
total 12
drwxrwxrwx 2 root root 0 Aug 12 12:01 ./
drwxrwxrwx 2 root root 0 Aug 12 12:01 ../
drwxrwxrwx 2 root root 0 Aug 12 12:01 foo/
russ@DESKTOP-K1JHN54:~$

This is fixed on an internal build. Should hit an Insider build before too long:

russ@RUSSALEX-BOOK:~$ ln -s /mnt/c/Temp/ ~/temp
lrwxrwxrwx 1 russ russ 12 Aug 12 18:56 temp -> /mnt/c/Temp//
russ@RUSSALEX-BOOK:~$ ll temp/foo/
total 4
drwxrwxrwx 2 root root 0 Aug 12 18:55 ./
drwxrwxrwx 2 root root 0 Aug 12 18:55 ../
drwxrwxrwx 2 root root 0 Aug 12 18:55 bar/
-rwxrwxrwx 1 root root 0 Aug 12 18:55 bar.txt*
-rwxrwxrwx 1 root root 0 Aug 12 18:55 foo.txt*
russ@RUSSALEX-BOOK:~$ ll temp/foo/bar
total 0
drwxrwxrwx 2 root root 0 Aug 12 18:55 ./
drwxrwxrwx 2 root root 0 Aug 12 18:55 ../
-rwxrwxrwx 1 root root 0 Aug 12 18:55 baz.txt*
russ@RUSSALEX-BOOK:~$

Thank you for reporting this, this is definitely a bug. I’ve filed a bug internally and will start taking a look at a fix.

The team’s focus is on providing new functionality and fixes to the Windows Insider builds. Only security updates and very select fixes will be pushed out through Windows Update to the 14393.x builds. We discuss this a bit on our WSDL blog here.

According to https://msdn.microsoft.com/en-us/commandline/wsl/release_notes, this is fixed in Build 14905.

@russalex

When testing I ran ln -s /mnt/c/tmp ~/temp instead of ln -s /mnt/c/tmp/ ~/temp. Forgot the all important ‘/’ at the end of tmp.

Guess what. I did the OPPOSITE of this and it worked for me. Omitting the slash after tmp made it work flawlessly. Go figure.

Hey, This is fixed in creators (Now that I updated).

On Tue, May 2, 2017 at 3:58 PM, Jack Hammons notifications@github.com wrote:

@derekriemer https://github.com/derekriemer What version of windows are you running? Use the ver command in CMD.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BashOnWindows/issues/650#issuecomment-298773684, or mute the thread https://github.com/notifications/unsubscribe-auth/AFGivcwuiDurAlRT5xJH_2U5HDzP3DDHks5r16cCgaJpZM4JLE78 .

–

Derek Riemer: Improving the world one byte at a time!

  • University of Colorado Boulder Department of computer science, 4th year undergraduate student.
  • Accessibility enthusiast.
  • Proud user of the NVDA screen reader.
  • Open source enthusiast.
  • Skier.

Personal website http://derekriemer.com