Git hooks: Permission denied on a new HDD

I recently got a new Samsung 860 EVO 1TB SSD to add to my existing 128GB SSD that was filling up fast. After setting up the SSD on my machine using fstab, I started moving all my vagrant boxes and projects to a new partition dedicated to development. I mounted all the partitions under my home folder, and gave myself ownership of the respective folders.

I was ready to submit a patch to Wikimedia’s Gerrit platform. When you commit code, Gerrit runs a git commit-msg hook to add a Change-Id to every patch that is submitted for review. Committing code locally gave me the following error,

hint: The ‘hooks/commit-msg’ hook was ignored because it’s not set as executable.
hint: You can disable this warning with git config advice.ignoredHook false.

The first obvious reason for this to happen would be if the execute bit was not set on the hook, so I ran the following command,

chmod +x .git/hooks/*

That did not fix the error. I also noticed that if I ran the command manually by entering,


I would continue to get the permission denied error,

bash: .git/hooks/commit-msg: Permission denied

But if I ran the following, I’d get a different output,

❯ sh .git/hooks/commit-msg
 sed: can't read : No such file or directory

One more thing to ensure is that the script starts with a !/bin/sh, which in my case was present at the top of the file. After searching for quite sometime, I came across this answer on the Unix Stack Exchange.

Following was what I had in my fstab,

UUID="1b4c2001-1138-4785-a8cf-5f89e580d6ba"  /home/abijeet/Development   ext4   defaults   0   2
UUID="0351a00c-14a9-4eb1-9201-7351ddf55315"  /home/abijeet/Others  ext4   defaults   0   2

The defaults on Debian Buster seem to set the noexec flag. This was confirmed when I ran, mount | grep noexec.

Once I knew what the issue was, the fix was straightforward,

UUID="1b4c2001-1138-4785-a8cf-5f89e580d6ba"  /home/abijeet/Development   ext4   defaults,exec   0   2
UUID="0351a00c-14a9-4eb1-9201-7351ddf55315"  /home/abijeet/Others  ext4   defaults,exec   0   2

There are more details on the Debian wiki about the various options that fstab can accept. Hope this helps someone save some time.

Leave a Reply