How to change environment variables for a specific vscode folder(workspace) - visual-studio-code

I have more than a couple of compiler that I use. I'm looking for a way to modify the path variables just for a folder(a project where vscode is used). This path should not disturb the user path variables.
host machine : Windows
Thanks,
Manish

Related

Can't appear environment variables editor when edit Path (System environment variable) on Windows 11

I freshly install C/C++ compiler in my new window 11 laptop using MinGW Installer. and when i try add bin folder path to System environment path variable (System Environment Variable > Path) there i can't see Environment Variables Editor instead I found System Variable Editor but my old windows 10 laptop show Environment Variables Editor.
I can't understand what happened. And I don't know how to edit system environment variables using System Variable Editor.
Windows 10 laptop show Edit Environment Variables:
Windows 11 laptop doesn't show Edit Environment Variables but here show System Variable Editor:
I am the new on this platform so please forgive me if I have made any mistakes.
Thank you.
In fact an environment variable is an entire string. Windows 10 just displays multiple values separated by semicolons in a user friendly way. If you want to add a new value, append the value you want at the end of the entire string, and make sure there is a semicolon between the value and the previous one.

vscode can't find buildifier on remote instance

I'm bumping into a weird vscode issue. I use vscode to ssh into my EC2 instance. I primarily use bazel as the dependency management and build system for development. I installed buildifier, and included in my path variable however vscode still doesn't detect it. If I type buildifier <some bazel build file> in the terminal in vscode, it works perfectly, but if I try to use the formatting shortcut on the file using vscode, it doesn't. I went to the extension settings, and in the remote settings I explicitly put buildifier as the executable command. Still not working. Any help would be appreciated.
Thanks!
It's likely that the path you've set is set somewhere that the vscode remote server isn't looking. So it might be in your shell path but not the vscode remote servers path when it starts up.
As a workaround find the full path of buildifier e.g.
whereis buildifier
Then simply copy past the full path of buildifier into your settings under the Bazel: Buildifier Executable section.

Visual Studio Code keeps changing my "python.pythonPath"

I have been using settings.json for a while now to share some project settings accross my different machines (which happen to be Linux, macOS and Windows). One of the settings I use is "python.pythonPath", which points to a interpreter inside the .venv created by the Poetry tool. Since Windows and linux-based operating system paths differ for virtualenvs, I need to set an environment variable with the proper path, e.g.: CLAYMEMOIRS_INTERPRETER.
I started noticing a problem where, whenever I launch visual studio code, my:
{
...
"python.pythonPath" : "${env:CLAYMEMOIRS_INTERPRETER}"
}
Gets automatically replaced with:
{
...
"python.pythonPath" : "c:\\GitHub\\claymemoirs\\.venv\\Scripts\\python.exe"
}
Which is the value of my environment variable. Anyone knows how I can prevent this behaviour? I did not do any updates or changed any plugins.
The problem persists, but newer releases indicate python.pythonPath is being deprecated in favor of python.defaultInterpreterPath. See here.
One of the reasons for deprecation is the questioned problem.
With the new python.defaultInterpreterPath set in the workspace settings file (.vscode/settings.json) you can use environment variables to set the project .venv path in a OS independant manner "${workspaceFolder}${env:CLAYMEMOIRS_INTERPRETER}". When someone from the team loads opens the project's folder in VSCode, the interpreter will appear on the selectlist, allowing developers to select the project interpreter without messing with other people's interpreters and, without changing the workspace path.

How is the PATH variable defined for the vscode process itself (not the integrated terminal)?

I'm currently using a vscode over a remote ssh connection and cannot figure out how to set the search PATH for the vscode process itself. I have set the PATH for processes run in the terminal in my .bashrc file, which is also sourced from .bash_profile.
In spite of this, vscode complains that pipenv is not on the path although it is visible to my integrated terminal session. In my .bashrc I am loading environment modules to load versions of needed libraries, which get put on the PATH. Since I created my virtualenv using pipenv in the terminal, it knows which python version to use and makes a link to it in the environment definition. Because of the way python virtual environments work, the actual python binary is copied to the virtual environment. And because vscode has hardcoded paths where to look for virtual environments it is able to find the correct version of python that is in use (despite it not seeing it in the PATH).
In addition, hardcoding the path to pipenv using the extension setting python.pipenvPath still produces a "not found" error.
Solutions that I have seen elsewhere suggest launching vscode from the command line so that the process inherits the PATH settings. However, this will not work over a remote connection.

Git Bash wit Visual Studio Code: how to set permanent PATH

I'm using VSCode with git bash and minGW. Every time I restart VSCode the PATH is reset to default. I add my path to mingw with export PATH=$PATH:/c/mingw/bin
How can be permanent changed? I created .bashrc in my code folder but it doesn't works
Thanks
Search for "path" in the windows control panel. you can then "edit the system environment variables". You can edit it in to the system path.
You will need to restart VSCode after you change it, then it will be there every time..
Note that in the future this may cause problems if you have a separate version of something using mingw dlls.