Windows command line tar “cannot connect to d: res

2019-06-15 12:21发布

问题:

Using Windows Command line with cygwin, chef and ruby installed. When trying

knife cookbook site install mysql

returns the following error

Begin output of tar zxvf D:/path/to/chef-repo/cookbooks/mysql.tar.gz  
STDOUT:  
STDERR: tar<child>: Cannot connect to D: resolve failed  
gzip: stdin: undexpected end of file  
tar: Child returned status 128  
tar:  Error is not recoverable: exiting now</code>

How can I remedy this issue? I can manually unzip using

tar zxvf mysql.tar.gz  

but this is less than ideal. I believe this has to do with the colon in filename but how can I change that in the knife or chef preferences?

回答1:

The reason is that tar interprets colons (:) in file names as meaning it is a file on another machine. You can disable this behavior by using the flag --force-local.

This is from an answer from here.



回答2:

I don't know a complete answer but have been seeing this on Linux machines lately:

$ date > today
$ tar -czf - today > to:day.tgz
$ tar -tzf to:day.tgz
ssh: connect to host to port 22: Connection refused
tar (child): to\:day.tgz: Cannot open: Input/output error
tar (child): Error is not recoverable: exiting now

gzip: stdin: unexpected end of file
tar: Child returned status 2
tar: Error is not recoverable: exiting now
$ tar -tzf - < to:day.tgz 
today
$ 

It appears that tar wants to do some sort of remote file processing because of the colon in the file name and you can fake it out by using some form of redirection or piping - for both reading and writing a tarball. I would still like to find an option or something to tell tar not to behave this way.



回答3:

Will the tar command work if ran from cmd? Also what if the output is to a local drive. Something else try this,

tar zxvf "D:/path/to/chef-repo/cookbooks/mysql.tar.gz"