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

Installation failure caused by CDPATH environment variable

From
Wincent Colaiuta <win@wincent.com>
Date
Jul 11, 2007, 16:59 UTC
Message-ID
<9693D8E9-6F11-4AA1-AFCA-7E8456FA6420@wincent.com>

This week I've installed Git on two different machines and one of them mysteriously failed making the "install" target in the "templates/Makefile". Specifically, the problem was occuring here:

         (cd blt && $(TAR) cf - .) | \
         (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)
And the error message was:

tar: This does not look like a tar archive tar: Skipping to next header tar: Error exit delayed from previous errors

Upon investigation, I discovered that the cause was that on the failing machine, the CDPATH environment variable was set and included "." (the current directory). This meant that upon executing:

         (cd blt && $(TAR) cf - .)

The data from tar was getting prepended with garbage because "cd blt" was echoing the path to the directory.

The workaround is to "unset CDPATH" or change the value of CDPATH so that it doesn't include the "." (although the latter is not very feasible because without "." at the front of CDPATH changing into a directory relative to the current directory can be quite painful).

What do you think about altering the templates/Makefile to make it more robust against this kind of environment?

Here's a possible patch:
 From 057630bdcfeee63b90468d1a69153171b15780c0 Mon Sep 17 00:00:00 2001
From: Wincent Colaiuta <win@wincent.com>
Date: Wed, 11 Jul 2007 18:43:59 +0200
[PATCH] Proof Makefile against possible problems with CDPATH environment

If the CDPATH environment variable is set and contains a period Bash may echo the current directory name while performing a cd, and when this extra output is piped to tar as part of template installation it can cause tar to abort with an error. This patch avoids this problem by invoking cd as a separate step prior to invoking tar.

Signed-off-by: Wincent Colaiuta <win@wincent.com>
---
  templates/Makefile |    3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/templates/Makefile b/templates/Makefile
index aaa39d3..3457ccb 100644
--- a/templates/Makefile
+++ b/templates/Makefile
@@ -46,5 +46,6 @@ clean:

  install: all
         $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(template_dir_SQ)'
-       (cd blt && $(TAR) cf - .) | \
+       cd blt && $(TAR) cf - . | \
         (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)
+       cd -
-- 
1.5.2.3
Next: Johannes Schindelin
Message 1 of 12 in “Installation failure caused by CDPATH environment variable”
  1. Wincent ColaiutaJul 11, 2007
  2. Johannes SchindelinJul 11, 2007
  3. David KastrupJul 12, 2007
  4. Junio C HamanoJul 12, 2007
  5. Wincent ColaiutaJul 12, 2007
  6. Johannes SchindelinJul 12, 2007
  7. Johannes SchindelinJul 12, 2007
  8. Junio C HamanoJul 11, 2007
  9. Uwe Kleine-KönigJul 17, 2007
  10. Junio C HamanoJul 17, 2007
  11. Wincent ColaiutaJul 17, 2007
  12. Uwe Kleine-KönigJul 17, 2007

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.