Why are VSCode extensions not working in SSH - visual-studio-code

I am using the Remote-SSH extension. When I SSH to a local VM that has Linux, or far away to my uni's pc lab, all my VSCode local extensions don't work, it doesn't show under the extensions pane -> local installed. So doing the keyboard shortcut for one says "command 'extension.advancedNewFile' not found". Why is this and how do I fix this?

The first diagram in https://code.visualstudio.com/docs/remote/ssh shows it clearly that only theme/UI extensions remain applicable when VSCode is under remote development mode,
If you want features of certain extensions, you have to install them on the remote machine (under EXTENSIONS | SSH: MACHINE_NAME - INSTALLED).

Related

WSL Distros not visible to VSCode or IntelliJ IDEs

For a few weeks now I have had this very strange issue and have been unable to resolve it:
I usually code on WSL2, and it used to work fine on this machine and user. But now, whenever I try to open the Remote Explorer in Visual Studio Code or try to open a "New Project from Existing Files" in an IntelliJ IDE, no WSL Distros show up.
They are still there - wsl -l -v lists them and I can open them in the terminal. Everything inside of them works (aside from opening VSCode).
In Windows Explorer, their filesystems do show up. But in Visual Studio Code the list of Distros is empty and I get an error message stating "Cannot read properties of undefined (reading 'name')" when I open the Remote Explorer. In IntelliJ IDEs, only my local drives appear where there used to be additional entries for WSL.
When I navigate to a directory in WSL in the terminal and then execute code ., it opens a VSCode window, but then I get the notification "No WSL distros found".
Interestingly, previously opened projects in IntelliJ IDEs can still be opened (but I am getting Line-Ending issues).
I have tried reinstalling the WSL extension in VSCode, restarting the LXSSManager-Service, doing a network reset with netsh winsock reset, netsh int ip reset, ipconfig /release, ipconfig /renew, ipconfig /flushdns - and I have tried reinstalling VSCode entirely... to no avail. I have also looked at the registry entries for the WSL Distros under Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\, and they look fine to me.
I have also uninstalled my non-primary distros and reinstalled them - same issue across all installed distros, old or freshly installed.
I am sadly unable to specify how to reproduce the issue as everything used to work in this setup and nothing was deliberately changed.
My Windows version is Windows 11 Version 22H2 (OS Build 22621.963).

Extensions on the remote machine are not recognized by Remote-SSH extension

I have a Linux machine with VSCode on it, with extensions installed at /home/myuser/.vscode/extensions/. Everything runs great. However, now I would like to connect to that machine remotely with "Remote - SSH" from a VSCode instance that runs on another computer. The connection was successful, but the extensions are all grayed-out and have "Install in SSH:..." buttons.
How can I get VSCode to find the extensions already installed on the remote (Linux) machine?
The extensions were installed using VSCode on the remote machine.
I looked through the settings for something that might have to do with it, but couldn't find. I didn't install anything remotely yet ("Install in SSH:...") because I was afraid that it might clash with the existing installation.

why my vscode does not have the same libraries installed in wsl?

I'm using wsl and it runs codes in vscode pretty fine and I have different libraries which I installed through pip and conda in wsl but when I run that code using vscode itself it doesn't recognize the libraries or even pip itself.
I don't have any other environment.
I should add that I installed the packages globally using conda install ... or pip install ... in base environment and I only have base environment and I run my code through code . and I also have python and remote wsl extensions installed in my vscode.
what can be the problem?
I don't have much personal experience with this, but I found some useful information in this Stack Overflow question (even though it doesn't utilize conda), along with https://code.visualstudio.com/docs/remote/wsl-tutorial#_python-development.
I also found this blog post useful, even if it doesn't cover WSL.
In short, make sure you:
Have installed the Python extension (by Microsoft) in VSCode. This is critical for being able to detect and select the Python interpreter. You don't mention having this in place, so I believe this is your likely problem.
You have done this already, but including it for others who might read this later -- Install the Remote - WSL extension (or the Remote Development extension pack) in VSCode.
You are also doing this already -- Start VSCode from inside your WSL distribution. Alternatively, you can start VSCode from Windows and then select the Remote WSL - Reopen Folder in WSL from the Command Palette (also accessible from the "Remote" Status Bar).
In VSCode, open the Command Palette with Shift+Ctrl+P, search for the Python: Select Interpreter command, and you should find your Conda environment in the list.
After selecting this, you should find that your project is using the interpreter and modules that you have installed via conda.
One thing I did to overcome this issue is go to Extensions -> Local (You should have two tabs there, Local and WSL:DISTRO) DISTRO refers to whatever DISTRO you're using, you will see that some of the local extensions are disabled in the current workspace (WSL) and there is a little cloud icon in the WSL:DISTRO tab that says install Local Extensions in WSL:DISTRO once you click that it will let you choose which extensions to install and you should be good to go!

Is it possible to open VSCode from Windows terminal while SSH'ed into a virtual machine?

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.

VScode is forcing my extensions to be installed on WSL

I am trying to install platformIO an IOT tools extension and VScode installs it on wsl with no option for me to change to a local installation. Because it has a lot of dependence on IO and the extension just uses python it is really important for that it is installed locally. Is there any way to do this?
The green space in the bottom left tells you what "OS" VScode is using (win or one of the multiple WSL you might have on your system). It looks like this for WSl
or empty like this for windows
just click on it to change it. Extentions are installed to the respective environment/OS.