spmjs / node-scp2

[MAINTAINER WANTED] A pure javascript scp program based on ssh2.
385 stars 96 forks source link

0.2.0 always gives "Error: handle is not a Buffer" #21

Open domenic opened 9 years ago

domenic commented 9 years ago

See for example https://travis-ci.org/whatwg/streams/builds/43789094#L1383

compared to https://travis-ci.org/whatwg/streams/builds/39141547#L863 with 0.1.4

(Also I might suck at shell scripting but I can't my Travis builds to fail when ssh2 throws an error :-/turns out I need to use Travis's script hook instead of after_success)

domenic commented 9 years ago

This seems related to the fact that I am trying to scp into directories which don't yet exist, since scping to index.html works fine. My guess is that 0.1.4 would do a mkdir -p equivalent for me, whereas 2.0.0 stopped doing that. (The fact that the error message sucks is presumably a separate bug.)

alxlv commented 9 years ago

It does not work for me too.

Fr33maan commented 9 years ago

Exactly the same errors, does it come from scp2 or from a dependency ?

ChristopherHackett commented 9 years ago

Same here. if I drop the version down to 0.1.4 it works.

airyland commented 9 years ago

also with 0.2.2

lepture commented 9 years ago

Maybe it is related to https://github.com/spmjs/node-scp2/pull/32

airyland commented 9 years ago

@lepture

https://github.com/spmjs/node-scp2/blob/master/lib/client.js#L225 https://github.com/spmjs/node-scp2/blob/master/lib/client.js#L234

The errors are "Permission denied".

image

Nepoxx commented 8 years ago

Are you guys only seeing this on a specific platform?

For me (Ubuntu -> Ubuntu) scp2 0.2.2 creates the folders just fine, but for my coworker (Windows -> Ubuntu), the created folders lack the proper permissions (-x) and gives the Error: handle is not a Buffer error.

Nepoxx commented 8 years ago

The issue is that upload calls mkdir with incorrect attributes. attrs.mode is set to what fs.stat() returns for a file, which is not in the CHMOD format (0755 and whatnot).

Also, unfortunately, in windows the permissions on folders will not have the execute bit set, which means that folders will not be executable on the remote host.

 attrs.mode = attrs.mode ? '0' + (attrs.mode & 0777).toString(8) : '0755'

would solve the first issue, but I'm not sure how to deal with Windows permissions.

dev4q1 commented 8 years ago

I am getting the following issue:

../wp-gulp-automation/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:227
    throw new Error('handle is not a Buffer');
          ^
Error: handle is not a Buffer
    at SFTP.write (../wp-gulp-automation/node_modules/scp2/node_modules/ssh2/lib/SFTP/SFTPv3.js:227:11)
    at ../wp-gulp-automation/node_modules/scp2/lib/client.js:208:18
    at FSReqWrap.wrapper [as oncomplete] (fs.js:527:17)

Process finished with exit code 1

But I noticed that the file was created on the sftp-server but without content.

xujihui1985 commented 8 years ago

I found the attrs.mode on windows is not same as it on *nix. I have the same error in windows client, I just brucly set the attrs.mode='755', and it work

xiaoyann commented 6 years ago

because the dir of destination does not create before execute write

vikramparth commented 5 years ago

Any updates on this issue? I'm still running into it with the latest version of node-scp2.