colorls: Windows 10 with WSL - Permission denied @ rb_file_s_lstat

Description

Colorls does not display information on any files and/or directories if in between them there are some inaccessible files. In the below example I’m trying to list files of my C drive using WSL on windows 10:

root@machine  /mnt/c
λ  colorls
/mnt/c: Permission denied @ rb_file_s_lstat - /mnt/c/hiberfil.sys

In contrast the regular ls -l outputs the following information:

root@machine  /mnt/c
λ  ls -l
ls: cannot access 'hiberfil.sys': Permission denied
ls: cannot access 'pagefile.sys': Permission denied
ls: cannot access 'swapfile.sys': Permission denied
total 884K
...
dr-xr-xr-x 0 root root  512 Jun 20 11:48 'Program Files'
dr-xr-xr-x 0 root root  512 May 27 08:51  Users
dr-xr-xr-x 0 root root  512 Jun 25 14:11  Windows
-????????? ? ?    ?       ?            ?  hiberfil.sys
-r-xr-xr-x 1 root root 884K Dec  1  2006  msdia80.dll
-????????? ? ?    ?       ?            ?  pagefile.sys
-????????? ? ?    ?       ?            ?  swapfile.sys
...

BR /Slawek

About this issue

Most upvoted comments

same here too…

This error now only appears when I execute the colorls command inside the root directory of my C: \ or E: \

And that because of some file’s permission, for example one of these files is hiberfil.sys or swapfile.sys I wonder why it looks like this: -??? ? ? ? ? ? hiberfil.sys -??? ? ? ? ? ? swapfile.sys

This is because of the difference in permission handling with Windows filesystems and Unix-based filesystems. Unix traditionally stores file attributes as part of the directory. When you have permission reading the directory, you can list all the files and their attributes like file size and time stamp. With windows filesystems, this information is attached to the files themselves and you cannot even read the file size if you have no permission.

I’ve run into the same issue, after I accidentally delete authenticated user form my c drive…

This issue appears only when you tend to look at system protected stuff… And I have no idea how disaster-like it would be to delete user from C…🥵