开发者

Fabric put command gives fatal error: 'No such file' exception

I'm using Fabric 1.01, and in my fabfile I'm using the put command. The line is:

put('file.tar.gz', '~/file.tar.gz')

The server is in the env.hosts list. file.tar.gz is in the same directory as the fabfile, and i'm running the code from this directory.

When I run the code, it gets up to the point where it is running this put command. Just before failing the output is:

[uname@site.com] put: file.tar.gz -> ~/file.tar.gz

Fatal error: put() encountered an exception while uploading 'file.tar.gz'

Underlying exception message:
    No such file

Anyone know where this is coming from? The file definitely exists on my local machine, and I've also tried the second put() argument as just '/s开发者_StackOverflow中文版erver/path/to/' and I've tried using the absolute path of the file for the first put() argument, all to no avail.


I found this error message rather misleading. The message that is printed is:

Fatal error: put() encountered an exception while uploading 'local/path'

Underlying exception:
    No such file

Which leads you to think the problem is that somehow Python isn't seeing the file at local/path. I'm not certain this is never the case, but both in the case of the original question and in my case, the issue had nothing to do with that, and instead the issue was that the remote folder couldn't be found. Since this command won't automatically create any folders in the path that it doesn't find, it fails when it can't find any of the remote folders in the remote path.

In my particular case, the issue was that I provided a path that I intended to be interpreted as absolute on a remote Linux system, but I left off the initial /.


Oops, I got lazy when anonymizing the question. My code contained a tilde:

put('file.tar.gz', '~/file.tar.gz')

Apparently Fabric did the tilde interpolation using the home directory of my local machine, not the server. After replacing the tilde with the explicit path on the server it works fine.


The error could be more descriptive indeed. I thought that the file I was trying to upload was not found, but actually the directory where I wanted to upload the file to did not exist. After creating the directory, the error was resolved for me.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜