Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I type:

tar -cvf ~/changeset.tar --files-from ~/changeset.txt

it responds with this output:

tar:  admin/memberinformation.php            : Cannot stat: No such file or directory
tar:  business/clsPreferredAgencies.php      : Cannot stat: No such file or directory
tar:  business/clsPreferredAgencies_test.php : Cannot stat: No such file or directory
tar:  business/clscustomer.php               : Cannot stat: No such file or directory
tar:  business/clsfeedback.php               : Cannot stat: No such file or directory
tar:  business/clsleads.php                  : Cannot stat: No such file or directory
tar:  business/connection.php                : Cannot stat: No such file or directory
tar:  crons/daily_activity.php               : Cannot stat: No such file or directory
tar:  crons/not_closed_orders2.php           : Cannot stat: No such file or directory
tar:  crons/unaccepted_orders2.php           : Cannot stat: No such file or directory
tar:  js/jquery-1.4.2.js                     : Cannot stat: No such file or directory
tar:  sql/alter-project.sql                  : Cannot stat: No such file or directory
tar:  sql/buyerName.php                      : Cannot stat: No such file or directory
tar:  sql/preferredAgencies.sql              : Cannot stat: No such file or directory
tar:  sql/underwriters_list.sql              : Cannot stat: No such file or directory
tar:  user/close_selectedporject.php         : Cannot stat: No such file or directory
tar:  user/feedback.php                      : Cannot stat: No such file or directory
tar:  user/forum.php                         : Cannot stat: No such file or directory
tar:  user/initiatelead.php                  : Cannot stat: No such file or directory
tar:  user/leadprocess_detail.php            : Cannot stat: No such file or directory
tar:  user/mem_direc.php                     : Cannot stat: No such file or directory
tar:  user/qws.php                           : Cannot stat: No such file or directory
tar:  user/view_leaddetails.php              : Cannot stat: No such file or directory
tar:  user/viewfeedbackforusers.php          : Cannot stat: No such file or directory
tar:  user/viewfeedbacks.php                 : Cannot stat: No such file or directory
tar: Error exit delayed from previous errors
lsiden@lsiden2:~/titan$ ls admin/memberinformation.php 
admin/memberinformation.php

Here are the contents of ~/changeset.txt. In other words, a bunch of relative paths. As a sanity check:

$ ls admin/memberinformation.php 
admin/memberinformation.php

Why can't tar find any of these files even though they are clearly reachable from the current directory with the relative paths given?

FYI:

$ tar --version
tar (GNU tar) 1.15.1
share|improve this question

5 Answers 5

on ubuntu 10.04, tar --files-from or -T options

when a the last line contains space, tar failed. If you add a blank line at the end , it's run.

share|improve this answer

I had this same problem on my Mac (Darwin Kernel Version 10.8.0)

It turned out that two of the lines in my file.txt had an extra whitespace at the end of the line. Once I deleted the whitespace at the end of the lines, it worked fine. I confirmed this by re-adding a whitespace to the end of a line and it failed with an error stating:

Cannot stat: No such file or directory

So it appears that an extra whitespace anywhere or an extra blank line will cause a failure.

Also, FWIW, I was able to specify a file that contained either of the following:

./src/com/blarg/foo.java

or

src/com/blarg/foo.java

so either way was okay. it's just that pesky whitespace that is the problem.

share|improve this answer

I got it to work by running:

tar cvf ~/changeset.tar `cat ../changeset.txt`
share|improve this answer
1  
This might work in your case but realy does not bring any insight into your actual problem .. pretty useless as you mix up relative and absulute path without telling us about the diectory structure. -1 sorry. –  matthias krull Aug 5 '10 at 11:57

You have an extra space at the beginning of each line in changeset.txt.

EDIT: Also, did you by any chance create changeset.txt on a Windows machine? If so, there may be an extra ^M character at the end of each line. Most unix programs will consider this character to be part of the line (here, part of the file name), whereas Windows considers the ^M part of the newline sequence. You can see whether this is the case by running cat -A changeset.txt: normally there should just be a $ at the end of each line; if you see ^M$, you have a Windows file. The dos2unix command is often available to convert the line endings.

share|improve this answer
    
+1 for the eagle eye :) –  matthias krull Aug 2 '10 at 21:03
    
I tried to remove the extra space but it still wouldn't work. I finally had to do "tar cvf myfile.tar cat mystuff" instead of "-T mystuff" –  Larry Aug 4 '10 at 3:45
    
@Larry: before I noticed the extra spaces, I thought of Windows line endings (see my edit); could it have been both problems? –  Gilles Aug 4 '10 at 7:10

Most likely tar would love to be noticed about the current path. So instead of

admin/memberinformation.php

the changeset.txt should read

./admin/memberinformation.php

or alternatively contain the full path.

share|improve this answer
1  
admin/memberinformation.php and ./admin/memberinformation.php both work if the current working dir is the same that contains the files and both will not work if it is not the dir containing the files –  matthias krull Aug 2 '10 at 15:20
    
The currend dir indeed contains the files. Even when I removed the extra spaces, it didn't work. I finally had to take a different approach that I mentioned in the answer above. –  Larry Aug 4 '10 at 3:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.