After implementing export with archive generation (to build source releases) into the svn plugin, I encountered a "bug" which I've been struggling all day. Sometimes, it would fail for no obvious reason.
Now I have come to a really weird conclusion: There is no bug at all. Instead, it is as simple as this: tar under Windows (either msys or cygwin) cannot handle pathnames longer than 31 characters.
This sounds so hilarious, it can hardly be true, but it really seems to be the case.
Did anyone else experience that, too, or am I missing something?
D:\desktop>tar -cf D:/Desktop/SomeFolder/a.tar a.txt
tar: Cannot execute remote shell: No such file or directory
tar: D\:/Desktop/SomeFolder/a.tar: Cannot open: Input/Output error
tar: Error is not recoverable: exiting now
D:\desktop>mv SomeFolder SoFo
D:\desktop>tar -cf D:/Desktop/SoFo/a.tar a.txt
D:\desktop>mv SoFo Some
D:\desktop>tar -cf D:/Desktop/Some/a.tar a.txt
D:\desktop>mv Some SomeF
D:\desktop>tar -cf D:/Desktop/SomeF/a.tar a.txt
tar: Cannot execute remote shell: No such file or directory
tar: D\:/Desktop/SomeF/a.tar: Cannot open: Input/Output error
tar: Error is not recoverable: exiting now
Msys shell:
Profic@PROFIC-NBOOK /e/work/web/SDN/recipe-nddocs/cpp
$ tar cf /e/work/web/SDN/recipe-nddocs/cpp/rtfReader.tar rtfReader
Profic@PROFIC-NBOOK /e/work/web/SDN/recipe-nddocs/cpp
$
cmd shell:
E:\work\web\SDN\recipe-nddocs\cpp>c:\devel\msys\bin\tar cf e:\work\web\SDN\recipe-nddocs\cpp\rtfReader.tar rtfReader
/bin/tar: e\:\\work\\web\\SDN\\recipe-nddocs\\cpp\\rtfReader.tar: Cannot open: I/O error
/bin/tar: Error is not recoverable: exiting now
E:\work\web\SDN\recipe-nddocs\cpp>c:\devel\msys\bin\tar cf /e/work/web/SDN/recipe-nddocs/cpp/rtfReader.tar rtfReader
E:\work\web\SDN\recipe-nddocs\cpp>
So, yes, problem is there.
Ok, ok, a simply looking at tar --help I found the cause, tar (in Windows at least) doesn't support a directory parameter to -f. :D
You must specify always FILES only with -f (--file), not DIRECTORIES.
You must specify the origin DIRECTORY with -C (--directory).
This will do the trick:
D:\desktop\SomeFolder>tar -cf a.tar -C D:/desktop/SomeFolder a.txt
However, it is also bad,
The correct way is enclosing with quotes all directories and files, because the filenames/directories can contain spaces:
D:\desktop\SomeFolder>tar -cf "a.tar" -C "D:/desktop/SomeFolder" "a.txt"
I think that always it's recommended to enclose with quotes the filenames/directories when passing as a parameter to any program.
That's it :)
For more information, refer to the help of tar,
ie. the help says that you can do something like this:
example% cd fromdir; tar cf - .| (cd todir; tar xfBp -)
http://www.computerhope.com/unix/utar.htm
http://www.gnu.org/software/tar/manual/html_mono/tar.html