WSL Ubuntu Distro | How to solve `Operation not permitted` on cloning repository
I had the same issue. Try this:
sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata
Change the drive letter to whatever one you're having the issue with.
You can automatically mount your Windows drives under WSL with the metadata option that allows apps, like git, to use chmod and fix this issue.
Edit /etc/wsl.conf (create it if it doesn't exist). Add the following:
[automount]
options = "metadata"
Exit the WSL session and start it again.
Then never worry about it again.
/mnt/c/Users/...
is on the Windows NTFS partition itself, and not within the WSL's ext4
formatted system. Therefore you have to treat it as you would an NTFS partition on a USB stick on an actual Ubuntu installation, and accept the limitations of NTFS.
NTFS partitions do not support chmod
or similar Linux permissions commands, and unlike in actual Ubuntu instalations which don't error but don't make any permissions changes, WSL doesn't relay this information back to you, it simply errors out as you see here.
You cannot do a git clone
sanely into the /mnt/c/...
space within WSL because of the Linux permission schemas and chmod
not working right. This is a limitation of WSL in its current form.