Error: No such file (sftp liximomo extension)
Asked Answered
H

6

40

I have this problem when I upload a file on the server using the extension liximomo/vscode-sftp for visual studio code.

[error] Error: No such file
    at SFTPStream._transform
    at SFTPStream.Transform._read
    at SFTPStream._read
    

How I can fix this problem? I tried to upload files to different servers, so I guess it's not a server-related problem but an extension.

Headband answered 12/5, 2021 at 15:31 Comment(0)
A
66

This is apparently a brand new problem that has been introduced into the newer versions of VS Code. I have FOUND A SOLUTION that seems to work well, by modifying a single line in the extension code. This is only valid for version 1.12.9 of the liximomo.sftp extension.

Here are the steps:

  1. Shutdown / Quit VS Code.
  2. Locate the following file:
    Mac OS X:
    ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js

    Windows:
    C:\Users\account_name\.vscode\extensions\liximomo.sftp-1.12.9\node_modules\ssh2-streams\lib\sftp.js
  3. Make a backup copy of the file.
  4. Modify line 388, which should be:
    if ( code === STATUS_CODE . OK ) { changing it to:
    if (code === STATUS_CODE.OK || code === STATUS_CODE.NO_SUCH_FILE) {
  5. Save the file.
  6. Relaunch VS Code; test by uploading or downloading from your sftp server. The error should not be present.

The alternative solution involves downgrading your version of VS Code. This is not desirable as you are not getting the latest fixes, security patches, etc..

See the following links regarding this issue:

If you want to downgrade your VS Code; use this link to find the older versions:

https://code.visualstudio.com/updates/v1_55


CREDIT:
Bao from: https://blog.naver.com/PostView.nhn?blogId=pcgun70&logNo=222341271496
From their blog entry (translated by Google to English):

"At first, there was no solution, but Now, 12 hours later, the Holy One appeared, who told me how to solve it.files that sftp cannot find in the first place. There is a calling phrase, VScode is upgraded and an error is called. It came out. Actually, I did not solve the problem. Even if the file is not found, the same result as the success process is exported. It is just a modification. It is expected that a modified version will be released in the future."

Antechamber answered 13/5, 2021 at 18:7 Comment(6)
That worked for the time being but wonder why the add-in was released with this bug... shouldn't they have tests in place or some sort of quality check? This was a tiny one but imagine it would have affected upload and F*** things up on the server! Scary that it's used by 800k devs. Thanks for the quick fix man!Type
Actually this add-on has worked fantastic for many months; it was a recent change to the VS Code base that caused the add-on to start misbehave. The only issue is the maintenance of the add-on by the developer .. whom we have not yet heard from. So the community has kicked in and found a solution.Antechamber
This worked for me -> kubuntu linux, its not the first time I'd have to donwgrade vs code, but this time I coould solve it, thank youStigmatic
It didn't help me. SFTP v1.12.9. VSC 1.59.0Laforge
Tried it's working to me. macos big sur 11.4 liximomo.sftp-1.12.9 vscode 1.59.1 (Universal)Cannula
Yippee -- worked for me under widows 10 -- I'm in a better mood already today!Francophobe
P
93

There is a better fix on GitHub that works for upload and download via SFTP extension:

Do a search inside ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js for options.emitClose = false;

Add options.autoDestroy = false; after both instances.

- mrjcgoodwin commented 8 days ago

Persas answered 14/5, 2021 at 8:18 Comment(10)
This link shows where to make the changes github.com/Natizyskunk/ssh2-streams/commit/…Hamsun
did microsoft micromanaged a "solution" to this bug? @Hamsun the link is not working :( but thanks anyways..Adjournment
Tried but not working. macos big sur 11.4 liximomo.sftp-1.12.9 vscode 1.59.1 (Universal)Cannula
I'm curious, how did you manage to get this solution? I mean, how did you debug the issue? I just want to know if you don't mindDithionite
Deliciously hacky. Solved it for me, thanks for the answer.Juicy
This works for me too. I just need to close and then open the VS Code again after modifying sftp.js. Thanks.Tortosa
Yep, it works. Thanks. Remember to restart VSCode. I'm on Windows.Bogbean
Wonderful! Worked for me tooBeret
Thanks! On Windows do not forget to restart your VSCode after applying fix.Alisa
Really the best solutions....Ilo
A
66

This is apparently a brand new problem that has been introduced into the newer versions of VS Code. I have FOUND A SOLUTION that seems to work well, by modifying a single line in the extension code. This is only valid for version 1.12.9 of the liximomo.sftp extension.

Here are the steps:

  1. Shutdown / Quit VS Code.
  2. Locate the following file:
    Mac OS X:
    ~/.vscode/extensions/liximomo.sftp-1.12.9/node_modules/ssh2-streams/lib/sftp.js

    Windows:
    C:\Users\account_name\.vscode\extensions\liximomo.sftp-1.12.9\node_modules\ssh2-streams\lib\sftp.js
  3. Make a backup copy of the file.
  4. Modify line 388, which should be:
    if ( code === STATUS_CODE . OK ) { changing it to:
    if (code === STATUS_CODE.OK || code === STATUS_CODE.NO_SUCH_FILE) {
  5. Save the file.
  6. Relaunch VS Code; test by uploading or downloading from your sftp server. The error should not be present.

The alternative solution involves downgrading your version of VS Code. This is not desirable as you are not getting the latest fixes, security patches, etc..

See the following links regarding this issue:

If you want to downgrade your VS Code; use this link to find the older versions:

https://code.visualstudio.com/updates/v1_55


CREDIT:
Bao from: https://blog.naver.com/PostView.nhn?blogId=pcgun70&logNo=222341271496
From their blog entry (translated by Google to English):

"At first, there was no solution, but Now, 12 hours later, the Holy One appeared, who told me how to solve it.files that sftp cannot find in the first place. There is a calling phrase, VScode is upgraded and an error is called. It came out. Actually, I did not solve the problem. Even if the file is not found, the same result as the success process is exported. It is just a modification. It is expected that a modified version will be released in the future."

Antechamber answered 13/5, 2021 at 18:7 Comment(6)
That worked for the time being but wonder why the add-in was released with this bug... shouldn't they have tests in place or some sort of quality check? This was a tiny one but imagine it would have affected upload and F*** things up on the server! Scary that it's used by 800k devs. Thanks for the quick fix man!Type
Actually this add-on has worked fantastic for many months; it was a recent change to the VS Code base that caused the add-on to start misbehave. The only issue is the maintenance of the add-on by the developer .. whom we have not yet heard from. So the community has kicked in and found a solution.Antechamber
This worked for me -> kubuntu linux, its not the first time I'd have to donwgrade vs code, but this time I coould solve it, thank youStigmatic
It didn't help me. SFTP v1.12.9. VSC 1.59.0Laforge
Tried it's working to me. macos big sur 11.4 liximomo.sftp-1.12.9 vscode 1.59.1 (Universal)Cannula
Yippee -- worked for me under widows 10 -- I'm in a better mood already today!Francophobe
O
1

Not an answer to the problem, but solution in another (simple) way:

  1. install Run On Save VSCode extension

  2. write a deploy.sh script along the lines

    rsync -avz -e 'ssh -i /home/user/.ssh/id_rsa' --exclude '.history' --exclude '.vscode' --exclude '.git' --exclude '.gitignore' --exclude 'deploy.sh' ./ [email protected]:/home/user/public_html/
    
  3. add the following configuration to VSCode settings.json to trigger the deploy.sh script on file save:

    "emeraldwalk.runonsave": {
         "commands": [
             {
                 "match": ".*",
                 "isAsync": false,
                 "cmd": "${workspaceFolder}/deploy.sh"
             },            
         ]
     }
    
Ornelas answered 2/8, 2021 at 19:34 Comment(0)
C
1

Just switch to the second one:

enter image description here

Camorra answered 26/11, 2021 at 9:42 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Maverick
M
0

If someone still facing this problem in 2024, here is my case and solution.

Problem: Natizyskunk sftp fork work fine while I'm connecting by ftp, but starting to show "no such file" error when I trying switch to sftp. At the same time, connection with same exact credential via ssh client or console work just fine. So, it's definitely plugin problem.

Solution: Just remove leading slash in the "remotePath" parameter. So, if it was this:

"remotePath": "/folder/subfolder/"

you must try this:

"remotePath": "folder/subfolder/"

It solves error for me.

Minter answered 3/7 at 8:0 Comment(0)
N
-1

There is another solution only upgrading the ssh2 package from the extension. You just need to go to the extension path:

Windows: C:\Users\your-user\.vscode\extensions\liximomo.sftp-1.12.9

When you are there, change the version of ssh2 package on the package.json file to ^1.1.0. Finally, just run npm install.

You should restart VSCode.

Alternatively, you could use a fork of the repository that is active and fixing these issues: https://github.com/Natizyskunk/vscode-sftp

Napkin answered 17/9, 2021 at 4:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.