{"thread":{"id":"8988","subject":"Installation failure caused by CDPATH environment variable","startedAt":"2007-07-11T16:59:23Z","lastAt":"2007-07-17T20:19:22Z","messageCount":12,"participants":["Wincent Colaiuta","Johannes Schindelin","Junio C Hamano","David Kastrup","Uwe Kleine-König"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"47049","messageId":"9693D8E9-6F11-4AA1-AFCA-7E8456FA6420@wincent.com","threadId":"8988","inReplyTo":null,"subject":"Installation failure caused by CDPATH environment variable","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-07-11T16:59:23Z","receivedAt":"2007-07-11T16:59:23Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"This week I've installed Git on two different machines and one of  \nthem mysteriously failed making the \"install\" target in the  \n\"templates/Makefile\". Specifically, the problem was occuring here:\n\n         (cd blt && $(TAR) cf - .) | \\\n         (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)\n\nAnd the error message was:\n\ntar: This does not look like a tar archive\ntar: Skipping to next header\ntar: Error exit delayed from previous errors\n\nUpon investigation, I discovered that the cause was that on the  \nfailing machine, the CDPATH environment variable was set and included  \n\".\" (the current directory). This meant that upon executing:\n\n         (cd blt && $(TAR) cf - .)\n\nThe data from tar was getting prepended with garbage because \"cd blt\"  \nwas echoing the path to the directory.\n\nThe workaround is to \"unset CDPATH\" or change the value of CDPATH so  \nthat it doesn't include the \".\" (although the latter is not very  \nfeasible because without \".\" at the front of CDPATH changing into a  \ndirectory relative to the current directory can be quite painful).\n\nWhat do you think about altering the templates/Makefile to make it  \nmore robust against this kind of environment?\n\nHere's a possible patch:\n\n From 057630bdcfeee63b90468d1a69153171b15780c0 Mon Sep 17 00:00:00 2001\nFrom: Wincent Colaiuta <win@wincent.com>\nDate: Wed, 11 Jul 2007 18:43:59 +0200\n\n[PATCH] Proof Makefile against possible problems with CDPATH environment\n\nIf the CDPATH environment variable is set and contains a period\nBash may echo the current directory name while performing a cd,\nand when this extra output is piped to tar as part of template\ninstallation it can cause tar to abort with an error. This patch\navoids this problem by invoking cd as a separate step prior to\ninvoking tar.\n\nSigned-off-by: Wincent Colaiuta <win@wincent.com>\n---\n  templates/Makefile |    3 ++-\n  1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/templates/Makefile b/templates/Makefile\nindex aaa39d3..3457ccb 100644\n--- a/templates/Makefile\n+++ b/templates/Makefile\n@@ -46,5 +46,6 @@ clean:\n\n  install: all\n         $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(template_dir_SQ)'\n-       (cd blt && $(TAR) cf - .) | \\\n+       cd blt && $(TAR) cf - . | \\\n         (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)\n+       cd -\n-- \n1.5.2.3\n"},{"id":"47050","messageId":"Pine.LNX.4.64.0707111807470.4516@racer.site","threadId":"8988","inReplyTo":"9693D8E9-6F11-4AA1-AFCA-7E8456FA6420@wincent.com","subject":"Re: Installation failure caused by CDPATH environment variable","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-11T17:09:34Z","receivedAt":"2007-07-11T17:09:34Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 11 Jul 2007, Wincent Colaiuta wrote:\n\n> [describes the typical CDPATH problem]\n\nYou exported CDPATH.  You're guaranteed to run into problems with that.  I \ndoubt that your patch catches all problems in git, and even if we tried to \navoid breakage, you can only do so much about that.\n\nIt is _wrong_ to export CDPATH.\n\nHth,\nDscho\n"},{"id":"47081","messageId":"7vejje3a4k.fsf@assigned-by-dhcp.cox.net","threadId":"8988","inReplyTo":"9693D8E9-6F11-4AA1-AFCA-7E8456FA6420@wincent.com","subject":"Re: Installation failure caused by CDPATH environment variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-11T21:26:19Z","receivedAt":"2007-07-11T21:26:19Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Wincent Colaiuta <win@wincent.com> writes:\n\n>  install: all\n>         $(INSTALL) -d -m755 '$(DESTDIR_SQ)$(template_dir_SQ)'\n> -       (cd blt && $(TAR) cf - .) | \\\n> +       cd blt && $(TAR) cf - . | \\\n>         (cd '$(DESTDIR_SQ)$(template_dir_SQ)' && $(TAR) xf -)\n> +       cd -\n\nActually I suspect replacing the \"cd blt\" in the original with\n\"cd ./blt\", without changing anything else, would squelch the\nCDPATH problem.\n\nWe could write it as \"$(TAR) Ccf blt - .\" if we can rely on the\n'C' option, but I suspect it is a GNU extension.  Does anybody\nhave POSIX.1 handy?\n"},{"id":"47126","messageId":"86sl7u12m3.fsf@lola.quinscape.zz","threadId":"8988","inReplyTo":"Pine.LNX.4.64.0707111807470.4516@racer.site","subject":"Re: Installation failure caused by CDPATH environment variable","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-07-12T07:51:32Z","receivedAt":"2007-07-12T07:51:32Z","isPatch":false,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> On Wed, 11 Jul 2007, Wincent Colaiuta wrote:\n>\n>> [describes the typical CDPATH problem]\n>\n> You exported CDPATH.  You're guaranteed to run into problems with that.  I \n> doubt that your patch catches all problems in git, and even if we tried to \n> avoid breakage, you can only do so much about that.\n>\n> It is _wrong_ to export CDPATH.\n\nBut it is not our job to educate people about that.  So I'd just add\nsomething like\n\n[ \"X\" = \"X$CDPATH\" ] || unset CDPATH # ignore braindamaged exports\n\nto the top of possibly affected scripts and be done.\n\nAfter the first few dozen bug reports (which are just the tip of an\niceberg of people who say \"git is crap and fails in strange ways\") you\njust recognize that you should just make that somebody else's problem.\n\nI've done my fair amount of such educational tasks myself with\npackages of mine.  It just gets you annoyed more and more each time,\nit is tedious, it gets people get a bad opinion of both your software\n_and_ your person (try being friendly after the 20th actually\ntechnically completely unnecessary such request, while basically\nexplaining that you won't fix it because it is a Darwinian trap for\nstupid people and you want evolution to run its course).\n\nA one-liner that makes this somebody else's problem (if at all) is\nworth its weight in gold.\n\nTrust me on that.\n\nMy personal lowlight in that area are dozens of university and company\ndocument classes derived from some old AMSLaTeX class in prehistoric\ntimes that redefined \\endfigure in a way incompatible with quite a few\npackages.  Among them preview.sty written by me.\n\nAfter about 5 bug reports about 5 different classes, explaining what\nwas wrong and why it broke quite a few packages, not just\npreview-latex, and how people should fix it and how they should\ncomplain to the people giving them the package...  preview.sty just\npatches the problematic definitions if it has a reasonable guess that\nthey are in place, and blows out a stern and verbose warning\nexplaining where to complain and why.\n\nOf course, nobody ever does.\n\nDon't educate people.  Just don't trigger their problems.  Of course,\nthere are millions of ways of shooting oneself in the foot, but in\nthis case the same foot has been hit several times already.\n\n-- \nDavid Kastrup\n"},{"id":"47131","messageId":"7vodiivx50.fsf@assigned-by-dhcp.cox.net","threadId":"8988","inReplyTo":"86sl7u12m3.fsf@lola.quinscape.zz","subject":"Re: Installation failure caused by CDPATH environment variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-12T08:34:03Z","receivedAt":"2007-07-12T08:34:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Kastrup <dak@gnu.org> writes:\n\n> Don't educate people.  Just don't trigger their problems.  Of course,\n> there are millions of ways of shooting oneself in the foot, but in\n> this case the same foot has been hit several times already.\n\nYup.  We do exactly that in git-clone, git-sh-setup and\nt/test-lib to avoid getting bugged by this stupidity.\n"},{"id":"47137","messageId":"4C80B6B8-F6D6-4C8B-86F5-629B5662247C@wincent.com","threadId":"8988","inReplyTo":"7vodiivx50.fsf@assigned-by-dhcp.cox.net","subject":"Re: Installation failure caused by CDPATH environment variable","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-07-12T10:24:26Z","receivedAt":"2007-07-12T10:24:26Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 12/7/2007, a las 10:34, Junio C Hamano escribió:\n\n> David Kastrup <dak@gnu.org> writes:\n>\n>> Don't educate people.  Just don't trigger their problems.  Of course,\n>> there are millions of ways of shooting oneself in the foot, but in\n>> this case the same foot has been hit several times already.\n>\n> Yup.  We do exactly that in git-clone, git-sh-setup and\n> t/test-lib to avoid getting bugged by this stupidity.\n\nEl 12/7/2007, a las 9:51, David Kastrup escribió:\n\n> [ \"X\" = \"X$CDPATH\" ] || unset CDPATH # ignore braindamaged exports\n\nWhatever decision is taken in the end, I think we should avoid terms  \nlike \"stupidity\" and \"braindamaged\" to avoid causing possible  \noffense. Exporting CDPATH is a simple mistake that can be made  \ninadvertently or unwittingly, but very easily (Googling for \"export  \nCDPATH\" yields 18,000+ results, many of them purporting to be Bash  \n\"tutorials\").\n\nCheers,\nWincent\n"},{"id":"47140","messageId":"Pine.LNX.4.64.0707121234390.4516@racer.site","threadId":"8988","inReplyTo":"86sl7u12m3.fsf@lola.quinscape.zz","subject":"Re: Installation failure caused by CDPATH environment variable","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-12T11:37:18Z","receivedAt":"2007-07-12T11:37:18Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\n[please Cc' me if you already quote me and answer directly to my message]\n\nOn Thu, 12 Jul 2007, David Kastrup wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > On Wed, 11 Jul 2007, Wincent Colaiuta wrote:\n> >\n> >> [describes the typical CDPATH problem]\n> >\n> > You exported CDPATH.  You're guaranteed to run into problems with \n> > that.  I doubt that your patch catches all problems in git, and even \n> > if we tried to avoid breakage, you can only do so much about that.\n> >\n> > It is _wrong_ to export CDPATH.\n> \n> But it is not our job to educate people about that.  So I'd just add\n> something like\n> \n> [ \"X\" = \"X$CDPATH\" ] || unset CDPATH # ignore braindamaged exports\n> \n> to the top of possibly affected scripts and be done.\n\nWe have that already, and we're not done.\n\n> A one-liner that makes this somebody else's problem (if at all) is worth \n> its weight in gold.\n\nThat is right.  And a one-liner that pretends to be a solve-all, but is \nnot, is worth its weight in lead.\n\nI bet that in ten years we find yet another instance where exporting \nCDPATH, which you should not have done in the first place, breaks Git.\n\nCiao,\nDscho \"who chants wrong, wrong, wrong\"\n"},{"id":"47142","messageId":"Pine.LNX.4.64.0707121250170.4516@racer.site","threadId":"8988","inReplyTo":"4C80B6B8-F6D6-4C8B-86F5-629B5662247C@wincent.com","subject":"Re: Installation failure caused by CDPATH environment variable","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-07-12T11:52:58Z","receivedAt":"2007-07-12T11:52:58Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 12 Jul 2007, Wincent Colaiuta wrote:\n\n> El 12/7/2007, a las 10:34, Junio C Hamano escribi?:\n> \n> > David Kastrup <dak@gnu.org> writes:\n> > \n> > > Don't educate people.  Just don't trigger their problems.  Of \n> > > course, there are millions of ways of shooting oneself in the foot, \n> > > but in this case the same foot has been hit several times already.\n> > \n> > Yup.  We do exactly that in git-clone, git-sh-setup and t/test-lib to \n> > avoid getting bugged by this stupidity.\n> \n> El 12/7/2007, a las 9:51, David Kastrup escribi?:\n> \n> > [ \"X\" = \"X$CDPATH\" ] || unset CDPATH # ignore braindamaged exports\n> \n> Whatever decision is taken in the end, I think we should avoid terms \n> like \"stupidity\" and \"braindamaged\" to avoid causing possible offense. \n> Exporting CDPATH is a simple mistake that can be made inadvertently or \n> unwittingly, but very easily (Googling for \"export CDPATH\" yields \n> 18,000+ results, many of them purporting to be Bash \"tutorials\").\n\nSorry, my words were indeed to strong.  I apologise.  My only excuse is \nthat this crops up ever so often, and it does get slightly annoying.  Of \ncourse, you did not read all those mails, and so my words were unmerited.  \n\nFor an example, see\n\nhttp://article.gmane.org/gmane.comp.version-control.git/13736/match=cdpath\n\nCiao,\nDscho\n"},{"id":"47626","messageId":"20070717114024.GA12215@informatik.uni-freiburg.de","threadId":"8988","inReplyTo":"7vejje3a4k.fsf@assigned-by-dhcp.cox.net","subject":"Re: Installation failure caused by CDPATH environment variable","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-07-17T11:40:24Z","receivedAt":"2007-07-17T11:40:24Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello,\n\nJunio C Hamano wrote:\n> We could write it as \"$(TAR) Ccf blt - .\" if we can rely on the\n> 'C' option, but I suspect it is a GNU extension.  Does anybody\n> have POSIX.1 handy?\nI don't have POSIX.1 handy, but on Solaris 10, you need to say:\n\n\ttar cf - -C blt .\n\n(That is, Solaris' tar has the 'C' option, which is quite a good\nindication, that it's included in POSIX :-)\n\nBest regards\nUwe\n\n-- \nUwe Kleine-König\n\nhttp://www.google.com/search?q=gigabyte+in+bit\n"},{"id":"47660","messageId":"7vhco2ancg.fsf@assigned-by-dhcp.cox.net","threadId":"8988","inReplyTo":"20070717114024.GA12215@informatik.uni-freiburg.de","subject":"Re: Installation failure caused by CDPATH environment variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-07-17T18:37:03Z","receivedAt":"2007-07-17T18:37:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de> writes:\n\n> Junio C Hamano wrote:\n>> We could write it as \"$(TAR) Ccf blt - .\" if we can rely on the\n>> 'C' option, but I suspect it is a GNU extension.  Does anybody\n>> have POSIX.1 handy?\n> I don't have POSIX.1 handy, but on Solaris 10, you need to say:\n>\n> \ttar cf - -C blt .\n>\n> (That is, Solaris' tar has the 'C' option, which is quite a good\n> indication, that it's included in POSIX :-)\n\nOh, I cannot resist ;-)\n\nSolaris has unlink(2) capable of removing a directory, but I do\nnot think it is included in POSIX.\n"},{"id":"47662","messageId":"2D8FF91A-02B0-44AF-8B7C-5C46DD6AF352@wincent.com","threadId":"8988","inReplyTo":"7vhco2ancg.fsf@assigned-by-dhcp.cox.net","subject":"Re: Installation failure caused by CDPATH environment variable","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2007-07-17T19:07:37Z","receivedAt":"2007-07-17T19:07:37Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"\nEl 17/7/2007, a las 20:37, Junio C Hamano escribió:\n\n> Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de> writes:\n>\n>> Junio C Hamano wrote:\n>>> We could write it as \"$(TAR) Ccf blt - .\" if we can rely on the\n>>> 'C' option, but I suspect it is a GNU extension.  Does anybody\n>>> have POSIX.1 handy?\n>> I don't have POSIX.1 handy, but on Solaris 10, you need to say:\n>>\n>> \ttar cf - -C blt .\n>>\n>> (That is, Solaris' tar has the 'C' option, which is quite a good\n>> indication, that it's included in POSIX :-)\n>\n> Oh, I cannot resist ;-)\n>\n> Solaris has unlink(2) capable of removing a directory, but I do\n> not think it is included in POSIX.\n\nI'd say the answer is \"no\", \"C\" isn't in the POSIX tar specification.\n\nThe latest, Version 3, says \"the Shell and Utilities volume of IEEE  \nStd 1003.1-2001 no longer contains the tar utility\" (<http:// \nwww.opengroup.org/onlinepubs/009695399/basedefs/tar.h.html>).\n\nAnd Version 2, which does contain tar, does not list \"C\" as an option  \n(<http://www.opengroup.org/onlinepubs/7990989775/xcu/tar.html>).\n\nIn fact, the example they give for moving directory hierarchies is  \nexactly this:\n\n   (cd fromdir; tar cf - . ) | (cd todir; tar xf -)\n\nCheers,\nWincent\n"},{"id":"47668","messageId":"20070717201922.GA28072@informatik.uni-freiburg.de","threadId":"8988","inReplyTo":"7vhco2ancg.fsf@assigned-by-dhcp.cox.net","subject":"Re: Installation failure caused by CDPATH environment variable","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-07-17T20:19:22Z","receivedAt":"2007-07-17T20:19:22Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello Junio,\n\nJunio C Hamano wrote:\n> Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de> writes:\n> > (That is, Solaris' tar has the 'C' option, which is quite a good\n> > indication, that it's included in POSIX :-)\n> \n> Oh, I cannot resist ;-)\n> \n> Solaris has unlink(2) capable of removing a directory, but I do\n> not think it is included in POSIX.\nI don't have access to the POSIX documents, but it would surprise me if\nthey forbid unlink(2) being able to unlink directories. :-)\n\nYou need some effort to support tar -C and to catch directories in\nunlink.  So Sun put the effort in tar, because it may be needed to be\nconformant to POSIX or some other standard.\n\nBest regards\nUwe\n\n-- \nUwe Kleine-König\n\n<script>alert(\"This is a virus for Outlook\")</script>\n"}]}