diff --git a/run-command.c b/run-command.c
index 606791dc67..f9922b9ecc 100644
--- a/run-command.c
+++ b/run-command.c
@@ -139,6 +139,8 @@ int sane_execvp(const char *file, char * const argv[])
 	 */
 	if (errno == EACCES && !strchr(file, '/'))
 		errno = exists_in_PATH(file) ? EACCES : ENOENT;
+	else if (errno == ENOTDIR && !strchr(file, '/'))
+		errno = ENOENT;
 	return -1;
 }