VSCode extension's configuration get conflicts between Native Windows and WSL2 - visual-studio-code

I use VSCode for both Windows and WSL2. When VSCode connecting to WSL2, I can download extension for WSL2. I think it is independent from Windows.
But I found the extension share a same configuration for Windows and WSL2.
For excample, the extension CMake Tools. In its setting, I can set CMake Path. I want that, in Windows, the CMake Path is c:\packages\msys2\usr\bin\cmake.exe and in WSL2, the path should be /usr/bin/cmake.
But it seems if I change the configuration on Windows, the WSL's changes simultaneously. Vice versa.
Can I have independent configurations?

Related

vscode inside WSL vs Windows

In tutorial requirement is install vscode in windows and install Remote Development extension pack. Why not just install in wsl?
I've install vscode to wsl. When I run code in wsl I get message:
To use Visual Studio Code with the Windows Subsystem for Linux, please install Visual Studio Code in Windows and uninstall the Linux version in WSL. You can then use the `code` command in a WSL terminal just as you would in a normal command prompt.
Do you want to continue anyway? [y/N]
To no longer see this prompt, start Visual Studio Code with the environment variable DONT_PROMPT_WSL_INSTALL defined.
Which cons of run vscode in wsl as opposed to run it in Windows?
The WSL extension splits VS Code into a “client-server” architecture, with the client (the user interface) running on your Windows machine and the server (your code, Git, plugins, etc) running "remotely" in your WSL distribution.
When VS Code is started in WSL, no shell startup scripts are run.
The extension runs commands and other extensions directly in WSL so you can edit files located in WSL or the mounted Windows filesystem (for example /mnt/c) without worrying about pathing issues, binary compatibility, or other cross-OS challenges.
(source: MSFT DOCUMENTATION)
This is the architectural choice of Windows and - personally speaking - I feel like it's a choice to avoid conflicts and redundancies.
When running the WSL extension, selecting the 'Extensions' tab will display a list of extensions split between your local machine and your WSL distribution.
Installing a local extension, like a theme, only needs to be installed once.
Some extensions, like the Python extension or anything that handles things like linting or debugging, must be installed separately on each WSL distribution. VS Code will display a warning icon ⚠, along with a green "Install in WSL" button, if you have an extension locally installed that is not installed on your WSL distribution.

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!

How can I make vscode installed with flatpak able to use internal terminals to run certain programs in the system?

By looking up some information, I know that the programs installed by flatpak are all running in the sandbox. Is there a way to make the sandbox environment search for some of the system environment to type content?
The program I want to use in vscode's integrated terminal is located under /usr/libexec/tmp. But the path cannot be searched in vscode's integrated terminal. However, it can be searched in an external terminal and can run programs.
Can you do some configuration in vscode using flatpak installation to accomplish the above goals?
I tried to install Code-OSS using the aur source, and the code-OSS terminal is synchronized with the system terminal environment.
However, Code-OSS cannot log in using a github account.

Why are VSCode extensions not working in SSH

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).

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.