Without spending some time going through your assorted Windows file permissions, it's hard to say exactly what's going wrong.
Thankfully, I don't need to know that. The simple fix to resolve all your file permission woes is to use the noacl
option for all the Cygwin mounts.
Open /etc/fstab
in your favourite Cygwin text editor (or, normally, C:\cygwin\etc\fstab
in your favourite Windows one, provided it supports Unix line-endings [so not Notepad]). Mine previously looked like this:
# For a description of the file format, see the Users Guide
# http://cygwin.com/cygwin-ug-net/using.html#mount-table
# This is default anyway:
# none /cygdrive cygdrive binary,posix=0,user 0 0
If that last line is still commented out, delete the leading #
so the system will pay attention to it. It may not be commented out, in which case there'll be no #
to delete.
Then, to the list of options (that's the binary,posix=0,user
bit), add ,noacl
to the end. The relevant line in my /etc/fstab
then looked like the below:
none /cygdrive cygdrive binary,posix=0,user,noacl 0 0
Then close and reopen all your Cygwin applications (you may need to reboot), and you should stop seeing any permissions issues.
Note that if you've been doing complicated things with your mount points, you may need to edit multiple lines in /etc/fstab
, as well as any files that have accumulated in /etc/fstab.d
. The changes you'll need to make will be the same for all of these.
The noacl
option will result in Cygwin completely ignoring all NTFS access control lists. It'll still look at the DOS read-only attribute, but that's not tied to any user. This means it won't be able to tell if a file is executable based off permissions, either; instead, it assumes any file ending .bat
, .com
or .exe
is executable, as well as any file starting with #!
.
Further reading, if you're interested, from the Cygwin User's Guide:
When you run Git from the Windows command line, do you know if you're using Cygwin Git? If you're not sure, can you post the output from
git --exec-path
? – me_and – 2012-08-06T10:52:21.263No, I'm not using Cygwin git, I just checked. I prefer to use the non-Cygwin version of git because I'm using some hooks that assume it's being run from a Windows environment, not a Cygwin environment. – dmazzoni – 2012-08-06T14:29:33.540
I know I could switch to using Cygwin git, but that's not what I want to do - what I want to do is understand the relationship between Windows file permissions and Cygwin file permissions. How can I set permissions in Windows so that a file becomes readable in Cygwin? – dmazzoni – 2012-08-06T14:30:42.477