gtg092x / gulp-sftp

Gulp SFTP Deploy
140 stars 61 forks source link

Create Directory if not present #9

Closed udayms closed 10 years ago

udayms commented 10 years ago

Can gulp-sftp create a directory if it doesn't exist on the remote? For some reason, when I run my code, the code breaks with the following error if the directory is not already existing on remote:

events.js:72 throw er; // Unhandled 'error' event ^ Error: No such file

udayms commented 10 years ago

I managed to fix it by using the parent path. Thanks. Closing this issue.

danimajo commented 10 years ago

@udayms How did you fix this? I have the same issue, I am uploading a set of files, some of them are in subdirs, but these subdirs aren't created and I get:

[14:51:31] gulp-sftp: Uploaded: stammdaten.html => /home/danimajo/html/willi/test/stammdaten.html
[14:51:31] SFTP error or directory exists: Error: No such file home/danimajo/html/willi/test/app

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: No such file
udayms commented 10 years ago

@danimajo The documentation says as follows: options.remotePath Type: String Default: '/'

The remote path to upload too. This path should exist, though the child directories that house your files do not need to.

Which means, whatever is passed as the remotePath should exist. All recursive directories inside it will be taken care of. In your context, if you are uploading a file to willi/test, then in remotePath pass 'willi'. This directory must exist. The 'test' will be created if your source is also 'willi'.

Hope this helps :)

davismj commented 10 years ago

Doesn't help. I'm getting the same problem. I am using remotePath. For example, the first directory does exist on the server, and it works fine. The second directory does not, and it throws the error danimajo quoted and exits.

gtg092x commented 10 years ago

Can you make sure you have the latest version? Also can I get the OS of both your client and server? You might need to open a new issue if your problem is different the OPs.

nickdunn commented 9 years ago

I'm also having the same problem. Deploying from OSX to a MediaTemple grid server (presumably Unix not Windows!).

remotePath: '/html'

With the following error:

    [18:29:57] SFTP error or directory exists: Error: Failure /html

    events.js:72
            throw er; // Unhandled 'error' event
                  ^
    Error: No such file
        at SFTP._parse (/Users/nick/Sites/uxua/node_modules/gulp-sftp/node_modules/ssh2/lib/SFTP/SFTPv3.js:1090:23)
        at ChannelStream.<anonymous> (/Users/nick/Sites/uxua/node_modules/gulp-sftp/node_modules/ssh2/lib/SFTP/SFTPv3.js:72:10)
        at ChannelStream.emit (events.js:95:17)
        at ChannelStream.<anonymous> (_stream_readable.js:764:14)
        at ChannelStream.emit (events.js:92:17)
        at emitReadable_ (_stream_readable.js:426:10)
        at emitReadable (_stream_readable.js:422:5)
        at readableAddChunk (_stream_readable.js:165:9)
        at ChannelStream.Readable.push (_stream_readable.js:127:10)
        at Parser.<anonymous> (/Users/nick/Sites/uxua/node_modules/gulp-sftp/node_modules/ssh2/lib/Channel.js:102:25)

Using 0.1.4 from npm.

Even if I leave the remotePath to the default / I get this error, even though when I SFTP using Transmit with the same credentials I can upload files into the default root.

Using https://github.com/sindresorhus/gulp-ftp with the same credentials works fine.

gtg092x commented 9 years ago

@nickdunn - I'll create a new issue for you on this. Your project root directory is not getting created? Can you verify that the destination is unix?

chris-equis commented 9 years ago

I am having the same promble using 0.1.4 client machine: OSX, server machine: Ubuntu 14.10, auth SSH keys

WuJiangquan commented 6 years ago

I set remotePath such as "./pathA/pathB/pathC/", but it throwed an error too " no such file". Then I found a bug at line 238

fileDirs = fileDirs.filter(function(d) { return d.length >= remotePath.length && !mkDirCache[d]; [});](https://github.com/gtg092x/gulp-sftp/blob/master/index.js#L238)

fileDirs's origin value was ["./pathA/pathB/pathC","./pathA/pathB","./pathA"] and my remotePath was "./pathA/pathB/pathC/"
"./pathA/pathB/pathC".length < "./pathA/pathB/pathC/".length always . so at last the fileDirs (filter result) is an empty array. As a result , it won't run the function sftp.mkdir to create my remotePath "./pathA/pathB/pathC/". At last it works when I set my remotePath as "./pathA/pathB/pathC".

Dan503 commented 6 years ago

Why close the issue just because you found a work around? This is still an issue with the core plugin.

Instead of just erroring, it would be far more user friendly if it created any directories that don't currently exist.

I'm on version 0.1.5 and still getting this issue.

markymcfly commented 6 years ago

Make sure, you are using the DOCUMENT_ROOT for the "options.remotePath". To get the DOCUMENT_ROOT just run info.php on your server:

info.php: <?php phpinfo(); ?>

potapovnikita commented 5 years ago

The same problem. I’m use Mac OS Sierra -> Linux centos

iconicwp commented 4 years ago

For anyone else facing this issue - I found the directory is not created if it has a trailing slash. Without a slash, it worked.

Working: some/directory/structure Not Working: some/directory/structure/

iconicwp commented 4 years ago

Just noticed @WuJiangquan said the same thing, but hopefully this is more clear.