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

3

17

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:

[[email protected]] 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 '/server/path/to/' and I've tried using the absolute path of the file for the first put() argument, all to no avail.

Directorate answered 14/6, 2011 at 23:27 Comment(2)
Just point to the full path name ? ./file.tar.gz or /your/location/file.tar.gzIsomagnetic
The version on ubuntu 11.10 was buggy. Upgrading using 'pip' solved it for me.Carny
D
11

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.

Directorate answered 15/6, 2011 at 1:34 Comment(1)
The docs say that tilde should be valid, but there's a bug in Fabric that's not interpreting it properly.Mow
S
20

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 /.

Sheng answered 8/7, 2014 at 13:1 Comment(1)
This was also the issue for me. Remote path was in a folder that hadn't been made yet.Rimmer
D
11

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.

Directorate answered 15/6, 2011 at 1:34 Comment(1)
The docs say that tilde should be valid, but there's a bug in Fabric that's not interpreting it properly.Mow
G
0

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.

Girish answered 23/2, 2023 at 23:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.