# [PATCH 1/1] run-command.c: ignore bad permissions on dirs in PATH

4 messages from 2010-05-25 to 2010-05-26. Participants: Dale Rowley, Junio C Hamano, Johannes Sixt.
Thread: https://gitlist.dev/t/23893

## Dale Rowley, 2010-05-25 02:55

Subject: [PATCH 1/1] run-command.c: ignore bad permissions on dirs in PATH
Message-ID: <4BFB3C0A.2030505@gmail.com>
URL: https://gitlist.dev/e/4BFB3C0A.2030505%40gmail.com

```
All of my git aliases stopped working one day. For example, when I ran 'git ci'
(where 'ci' is an alias for 'commit') it printed out this error:

fatal: cannot exec 'git-ci': Permission denied

This error was confusing (I didn't have a 'git-ci' executable anywhere, so why
was it complaining about permissions?) and it took me a while to figure out that
this was happening because I happened to have a random directory in my PATH that
had permissions set incorrectly. Git should probably ignore this, and here is
one way to fix it, although I'm not sure if it's the best way.



Signed-off-by: Dale Rowley <ddrowley@gmail.com>
---
 run-command.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/run-command.c b/run-command.c
index c7793f5..a98282b 100644
--- a/run-command.c
+++ b/run-command.c
@@ -284,7 +284,7 @@ fail_pipe:
 		 * Do not check for cmd->silent_exec_failure; the parent
 		 * process will check it when it sees this exit code.
 		 */
-		if (errno == ENOENT)
+		if (errno == ENOENT || errno == EACCES)
 			exit(127);
 		else
 			die_errno("cannot exec '%s'", cmd->argv[0]);
-- 
1.7.1.226.g770c5.dirty

```

## Junio C Hamano, 2010-05-25 05:34

Subject: Re: [PATCH 1/1] run-command.c: ignore bad permissions on dirs in PATH
Message-ID: <7vaarownmv.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vaarownmv.fsf%40alter.siamese.dyndns.org
In-Reply-To: <4BFB3C0A.2030505@gmail.com>

```
Dale Rowley <ddrowley@gmail.com> writes:

> All of my git aliases stopped working one day. For example, when I ran 'git ci'
> (where 'ci' is an alias for 'commit') it printed out this error:
>
> fatal: cannot exec 'git-ci': Permission denied
>
> This error was confusing (I didn't have a 'git-ci' executable anywhere, so why
> was it complaining about permissions?) and it took me a while to figure out that
> this was happening because I happened to have a random directory in my PATH that
> had permissions set incorrectly. Git should probably ignore this, and here is
> one way to fix it, although I'm not sure if it's the best way.

As long as the issue is "a directory P on PATH is unreadable, and we tried
to see if P/git-ci is executable and reported failure by exiting", I think
your patch is a reasonable solution.

Thanks

```

## Johannes Sixt, 2010-05-25 07:01

Subject: Re: [PATCH 1/1] run-command.c: ignore bad permissions on dirs in PATH
Message-ID: <4BFB75DD.7030201@viscovery.net>
URL: https://gitlist.dev/e/4BFB75DD.7030201%40viscovery.net
In-Reply-To: <7vaarownmv.fsf@alter.siamese.dyndns.org>

```
Am 5/25/2010 7:34, schrieb Junio C Hamano:
> Dale Rowley <ddrowley@gmail.com> writes:
> 
>> All of my git aliases stopped working one day. For example, when I ran 'git ci'
>> (where 'ci' is an alias for 'commit') it printed out this error:
>>
>> fatal: cannot exec 'git-ci': Permission denied
>>
>> This error was confusing (I didn't have a 'git-ci' executable anywhere, so why
>> was it complaining about permissions?) and it took me a while to figure out that
>> this was happening because I happened to have a random directory in my PATH that
>> had permissions set incorrectly. Git should probably ignore this, and here is
>> one way to fix it, although I'm not sure if it's the best way.
> 
> As long as the issue is "a directory P on PATH is unreadable, and we tried
> to see if P/git-ci is executable and reported failure by exiting", I think
> your patch is a reasonable solution.

But it is not only about an unreadable directory. EACCES is also returned
when a "git command" is found that does not have execute permission:

$ touch ~/bin/git-frob	# ~/bin is in $PATH
$ git frob		# original git
fatal: cannot exec 'git-frob': Permission denied
$ ./git frob		# patched git
WARNING: You called a Git command named 'frob', which does not exist.
Continuing under the assumption that you meant 'ambox'
in 11.0 seconds automatically...

That is, when you write a new git command and forget to set execute
permission, you lose the "Permission denied" error. (Ditto if you
accidentally remove execute permission from an existing external git command.)

The question is which corner case is more important to cater for.

I don't have an idea how to solve both issues short of doing the PATH
lookup manually.

-- Hannes

```

## Dale Rowley, 2010-05-26 02:36

Subject: Re: [PATCH 1/1] run-command.c: ignore bad permissions on dirs in PATH
Message-ID: <4BFC8943.6090504@gmail.com>
URL: https://gitlist.dev/e/4BFC8943.6090504%40gmail.com
In-Reply-To: <4BFB75DD.7030201@viscovery.net>

```
> That is, when you write a new git command and forget to set execute
> permission, you lose the "Permission denied" error. (Ditto if you
> accidentally remove execute permission from an existing external git command.)

True, but after getting the warning that 'git-frob' doesn't exist, it
would probably only take a minute to figure out that 'git-frob'
permissions need to be fixed, and then it's understandable why git
choked on it. In contrast, it took me a while to discover my PATH
permissions problem, and even then it wasn't clear why git should die
because of a permissions problem on a directory that had little to do
with git.

Dale

```
