6

I am running Ubuntu 18.04, as a Subsystem for Windows. I have done this in mutliple PCs and never had this problem. I try to to git clone <repo>, and I get this:

Cloning into '<repo>'...
error: chmod on /mnt/c/Users/Efsta/Code/<repo>/.git/config.lock failed: Operation not permitted
fatal: could not set 'core.filemode' to 'false'

I tried the following:

  1. ❯ git config core.fileMode false, with this result fatal: not in a git directory

  2. ❯ git config --global core.filemode false

  3. ❯ git config --add --global core.filemode false

Nothing seems to work. I already tried a couple of answers here, but WSL seems a little bit more tricky. Anyone have any idea about how to solve this?

I have also tried everything in this question : https://stackoverflow.com/questions/1580596/how-do-i-make-git-ignore-file-mode-chmod-changes, nothing seems to work.

6

/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.

  • 2
    Ok let me confirm some things. Microsoft says, that I should develop in WSL within Windows, so I can modify them on both the WSL and Windows sides. So, in every other installation I had until now, I did the same. And if we assume that what youa re saying is correct, what would you recommend as a soution to my problem? – Dimitris Efst Feb 4 at 16:45
  • And to add to my above question. What do I do about ssh? Can I resuse the same key on both. There are situations like gcloud where I want to use my windows deve enviroment instead... – Dimitris Efst Feb 4 at 16:47
  • Also, previously I was using WLinux, which was slow, but witht the same underlying theory used the Windows filesystem, and I could do it as well. So, not an Ubuntu specific thing.Sorry for spamming you – Dimitris Efst Feb 4 at 16:50
14

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.

  • The command was successful but this did not change the issue for me. I still see "operation not permitted" as git tries to chmod .git/config.lock. – akohlsmith May 22 at 13:55
  • This did it, thanks! – user3738356 Sep 3 at 5:38
  • 1
    Worked for me. Is there some reason MS is not doing this when they mount windows locations automatically? – UpTheCreek Oct 10 at 15:27
  • Note that this is available after build 17063: docs.microsoft.com/en-us/windows/wsl/release-notes#build-17063 – pooya13 Dec 4 at 22:54
2

I was having the same issue. My solution is to git clone my repo in the default WSL location (it works), and use Visual Studio Code to remote access my WSL's repos. That way you won't have to use /mnt/c at all.

Links: https://code.visualstudio.com/docs/remote/wsl

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.