When working remotely via SSH or WSL in VSCode in MS Windows, I can right-click a file in the Explorer view and choose "Download", this will download the file to the local computer. But the default download folder is always C:\Users\$USERNAME\.ssh, which doesn't make sense for me. I can't find any settings related to this.
How can I change the default download folder in VSCode when working remotely via SSH or WSL?
Related
Following the method provided in the official documentation here, I turned on sync for [Keyboard Shortcuts] keybindings.json, [User Snippets] cpp.json and [Settings] settings.json.
While VSCode Windows and VSCode on WSL on the same machine share the common keybindings.json and cpp.json files, WSL and Windows do not share the same settings.json file. The Windows version resides as:
C:\Users\Tryer\AppData\Roaming\Code\User\settings.json
and the WSL version resides as
\\wsl$\Ubuntu-20.04\home\Tryer\.vscode-server\data\Machine\settings.json.
These are two different files. When I open code . from within WSL, and issue command Settings Sync: Show Synced Data, clicking on the settings.json file picks up the Windows version C:\Users\Tryer\AppData\Roaming\Code\User\settings.json.
How does one resolve this conflict surrounding which settings.json file is synced on the same machine that runs both Windows and WSL?
I'm having problems setting up a vscode environment on a remote machine. The ".vscode-server" folder is in my home directory (/home/ID/) which is limited to 1gb.
How do I specify a new location for the extension that I want to install in my remote machine ?
The solution was in fact trivial:
In the remote server, create a symbolic link between /home and a chosen directory. When launching the ssh connection with vscode, vscode-server and all the extensions will be installed in the chosen dir.
I'm working on some tutorials and trying to do something, but no idea if it can be done. I am using windows terminal in Windows 10. I have an Ubuntu virtual machine running.
I'd like to:
Open Windows terminal
SSH into the Linux Virtual Machine
Type in the code . command and have it open a version of VS Code on my Windows PC that is working on the folder in the Ubuntu VM.
I tried install code locally and on the command line in the other machine, but it doesn't work. I am sure there are other ways to do this but wanted to explain how I was doing it to show I at least tried something. Thanks for your help.
It's not quite as easy as the code . technique you get with the Remote - WSL extension, but Microsoft also provides a Remote - SSH extension that can be used to directly access the remote machine (without requiring WSL in-the-middle).
Once the Remote - SSH extension is installed in VSCode (and it may have already been installed in an extension pack with the WSL extension), and you have installed an OpenSSH client in Windows, there are several ways to access files on the remote host through SSH:
From the Command Palette (Ctrl+Shift+P), type Remote SSH to filter on those commands. From Connect to Host, you can add a new configuration, etc.
From the Activity Bar on the left, select the Remote Explorer icon, then in the dropdown at the top, select SSH Targets. You can add hosts here through the + icon.
There's a direct shortcut to Open a Remote Window at the far left of the status bar. This will give you similar filter options on the Command Palette as above.
Once a host is configured, you can browse it just as (well, almost) if it were local, open files, edit, etc. The one thing you can't do (as far as I'm aware) is any type of sudo/su editing on files that you don't have permissions to directly.
Full details in the VSCode docs here.
I open my vscode with code . command from WSL terminal because I want to work directly in my WSL. It works fine and for example, the file explorer of vscode shows directory structures based on WSL machine and not based on my Windows machine.
My problem is however that, when I save a workspace using File -> Save Workspace As, it saves it again as a workspace in my Windows machine. So when I close and open my vscode again and use Open Workspace... to open the already saved workspace(in previous step), explorer reads directories from Windows machine.
You might ask what's the difference between saving files in /mnt/c/Users/[user]/Desktop or C:\Users\[user]\Desktop, but the problem is two things:
I might open a session from a directory in WSL that is (unlike Desktop) inaccessible from Windows.
Even if my Desktop is my current working directory, I may add another directory to my workspace (using Add Folder to Workspace...) and even if it is a path accessible from Windows, the next time I open the workspace, I will get an exclamation mark and such an error near that directory in explorer:
C:\mnt\d\Files_And_Downloads\Google Drive_Code . Can not resolve workspace folder
I suspect this is a bug, vscode has mixed the WSL path and Windows path. So anyone who uses Remote - WSL extension and can tell me what's going on here?
I've been using Bash for Windows recently (its the Ubuntu "app") and I can open VSCode from the bash command line but when I try to save any modifications I've made to the file, it just says permission denied.
I've tried creating the files directly from VS Code's terminal but in that case it doesn't print out an error message but it also doesn't save anything.
That happens because you dont have permissions to write in the system32 folder. If you run the Ubuntu application as an administrator, you'll get the permissions to write. However, you won't be really in that file, because of the way that the virtualization of files and errors might happear doing so, and I do not recommend to run the console in a privilege mode (for seccurity issues).
Fortunately, in version 1903 of Windows 10, this will change, and you'll be able to navigate the WSL folders via Windows Explorer, and for sure that issue will disappear.
Edit: the best practice, you do the work in a folder in the Windows File System, and cd to there in the WSL console. VSCode has this integrated very well, if you have an open file in VSCode you can just do New Terminal and choose a WSL terminal. The terminal will already be in the folder where you file is.