当 VS 代码无法将文件保存到 SSH 远程服务器时,我该怎么办?

What can I do when VS code can NOT save file to SSH remote server?

我今天使用 VS Code 编写了一些代码。突然,当我按下 CMD + s 时,VS Code 告诉我:

Failed to save 'example.py': Unable to write file

remote+123.255.255.255/data/example.py' (Canceled: Canceled)

当我打开另一个 SSH 远程项目时,SSH 连接看起来仍然有效。 然后我想也许备份是个好主意,所以我按下右下角的Saved As按钮并输入路径/data/example_backup.py得到警告:

Please enter a path that exists

即使我尝试了 /data/example.py,我仍然收到此警告。

然后 show local 按钮提醒我可以将此文件保存到本地磁盘。按下 show local 按钮并选择本地目录后,VS Code 做出了一些反馈:

Unable to read file 'vscode-remote://ssh-remote+123.255.255.255/data/example.py' (Canceled: Canceled)

但似乎备份成功了,因为文件已经在本地文件夹中了。

是否有重新连接 SSH 远程并再次保存的解决方法?

接下来是,例如,microsoft/vscode-remote-release issue 5215 (after hibernation) or 4686 (WSL2)

为了测试,请尝试 Reload Window 命令,然后查看连接是否已恢复(您正在处理的文件也已恢复,准备保存)。