git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Installation failure caused by CDPATH environment variable
@ 2007-07-11 16:59 Wincent Colaiuta
  2007-07-11 17:09 ` Johannes Schindelin
  2007-07-11 21:26 ` Junio C Hamano
  0 siblings, 2 replies; 12+ messages in thread
From: Wincent Colaiuta @ 2007-07-11 16:59 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2007-07-17 20:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-11 16:59 Installation failure caused by CDPATH environment variable Wincent Colaiuta
2007-07-11 17:09 ` Johannes Schindelin
2007-07-12  7:51   ` David Kastrup
2007-07-12  8:34     ` Junio C Hamano
2007-07-12 10:24       ` Wincent Colaiuta
2007-07-12 11:52         ` Johannes Schindelin
2007-07-12 11:37     ` Johannes Schindelin
2007-07-11 21:26 ` Junio C Hamano
2007-07-17 11:40   ` Uwe Kleine-König
2007-07-17 18:37     ` Junio C Hamano
2007-07-17 19:07       ` Wincent Colaiuta
2007-07-17 20:19       ` Uwe Kleine-König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).