git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: "fatal: index-pack failed" on git-clone

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 8, 2009, 18:49 UTC
Message-ID
<7vd48b6md8.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4103BA41-39E4-496F-A76F-17D84F30EA21@uchicago.edu>
Fritz Anderson <fritza@uchicago.edu> writes:
Show 29 quoted lines
> On Jul 8, 2009, at 12:34 PM, Junio C Hamano wrote:
>
>> Which makes the initial "sudo git clone..." find git in _your_ path
>> before sanitization (and that is why it even starts), but then the path
>> is nuked for the git process it launches, and we cannot find
>> git-index-pack on the PATH.
>>
>> But this should be fine, as git is expected to find git-index-pack in
>> its GIT_EXEC_PATH that is compiled in the binary of "git" itself.
>>
>> Which makes me suspect that your "git" in /usr/local/bin may be
>> misconfigured.  You might want to check what these tell you.
>>
>> 	$ git --exec-path
>> 	$ /usr/local/bin/git --exec-path
>
> Glad to oblige. These are the four possibilities:
>
> $ git --exec-path
> /usr/local/libexec/git-core
> $ /usr/local/bin/git --exec-path
> /usr/local/libexec/git-core
> $ sudo git --exec-path
> /usr/local/libexec/git-core
> $ sudo /usr/local/bin/git --exec-path
> /usr/local/libexec/git-core
> $
>
> Same path every time, sudo or not, full path to git or not.

Hmm, there is something fishy going on, and I am a bit frustrated not being able to see what it is.

The callpath should look like this:
  git.c::main()
  -> setup_path()
  -> cmd_clone()
     -> transport_fetch_refs()
        -> fetch_refs_via_pack()
           -> fetch_pack()
              -> do_fetch_pack()
                 -> get_pack()
                    -> start_command(), running either
                       "index-pack" or "unpack-objects"
                       on the incoming stream

and start_command() forks and eventually does execv_git_cmd() which is a thin wrapper around execvp().

The PATH exported when this execvp() runs should have been adjusted to have the exec-path at the beginning by calling setup_path() and this is done way before cmd_clone() was called by git.c::main() function.

What am I not seeing? There should be something obvious that I am missing. I do not see how your original command can fail with "exec failed: No such file or directory".

Could you try your original (non-working) command with this debug patch?
 exec_cmd.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/exec_cmd.c b/exec_cmd.c
index 408e4e5..000910b 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -101,6 +101,9 @@ void setup_path(void)
 	const char *old_path = getenv("PATH");
 	struct strbuf new_path = STRBUF_INIT;
 
+	trace_printf("trace: setup_path: the $PATH was: %s\n",
+		     old_path ? old_path : "NULL");
+
 	add_path(&new_path, git_exec_path());
 	add_path(&new_path, argv0_path);
 
@@ -110,7 +113,8 @@ void setup_path(void)
 		strbuf_addstr(&new_path, "/usr/local/bin:/usr/bin:/bin");
 
 	setenv("PATH", new_path.buf, 1);
-
+	trace_printf("trace: setup_path: the $PATH is now: %s\n",
+		     getenv("PATH") ? getenv("PATH") : "NULL");
 	strbuf_release(&new_path);
 }
 
@@ -138,7 +142,8 @@ int execv_git_cmd(const char **argv) {
 	execvp("git", (char **)nargv);
 
 	trace_printf("trace: exec failed: %s\n", strerror(errno));
-
+	trace_printf("trace: the $PATH was: %s\n",
+		     getenv("PATH") ? getenv("PATH") : "NULL");
 	free(nargv);
 	return -1;
 }
Previous: Fritz AndersonNext: Daniel Barkalow
Message 6 of 18 in “"fatal: index-pack failed" on git-clone”
  1. Fritz AndersonJul 8, 2009
  2. Junio C HamanoJul 8, 2009
  3. Fritz AndersonJul 8, 2009
  4. Junio C HamanoJul 8, 2009
  5. Fritz AndersonJul 8, 2009
  6. Junio C HamanoJul 8, 2009
  7. Daniel BarkalowJul 8, 2009
  8. Fritz AndersonJul 8, 2009
  9. Fritz AndersonJul 8, 2009
  10. Johannes SixtJul 8, 2009
  11. Jeff KingJul 8, 2009
  12. Fritz AndersonJul 8, 2009
  13. Johannes SixtJul 9, 2009
  14. Junio C HamanoJul 8, 2009
  15. Jeff KingJul 9, 2009
  16. Michael J GruberJul 9, 2009
  17. A Large Angry SCMJul 9, 2009
  18. Jeff KingJul 13, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.