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,

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,

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,

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

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,

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,

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