VSCode: set terminal shell on workspaces after latest update - visual-studio-code

On VSCode, if I needed a different terminal shell on a certain workspace, I had added the following setting in the workspace file (.code-workspace):
"settings": {
"terminal.integrated.shell.windows": "path\to\the\shell.exe"
}
After the latest update (April 2021 - version 1.56) this doesn't work anymore and I get this warning:
This is deprecated, use #terminal.integrated.defaultProfile.windows# instead
If I replace the setting name with the suggested one I get:
This setting can be applied only in application user settings
How can I set a different terminal shell per workspace?

Unfortunately, here is the same issue: https://github.com/microsoft/vscode/issues/123031 from https://github.com/microsoft/vscode/issues/123133.
Issue 123133 was closed 05/05/2021 with a temporary fix, see that issue and https://github.com/microsoft/vscode/commit/006591a7cfa31b9778e712b742b6e37f4afd0ed9. Here is my Insiders Build workspace settings file after the fix:
Note the previous error message is gone. I suspect that this "fix" will be in a point release to v1.56 fairly soon rather than waiting for v1.57.

As zendu pointed out, there's an open issue about it with a temporary fix:
A temporary fix was added to re-enable workspace shell settings when "terminal.integrated.allowWorkspaceConfiguration": true is set #122104
I tried it and it seems to work (at least for now).

Related

VS Code's file changes watcher stopped working

I have vsc version 1.63.2. I'm getting the following notification:
"File changes watcher stopped unexpectedly. A reload of the window may enable the watcher again unless the workspace cannot be watched for file changes."
When I click the reload button, the issue is temporarily fixed and Source Control shows changes to my files. Git in CLI is working fine; git log --raw shows changes to my files correctly. I've tested brand new and old repositories and workspaces. The problem occurs in all of them. Any help troubleshooting this is greatly appreciated!
I just ran into this issue today and found my solution by viewing the "Window" logs using the "Developer: Open Log File..." command from the Command Palette.
In my case, the problem was that I had added a folder to my workspace that I had since deleted on the file system. The log in question looked something like:
... [error] [File Watcher (parcel)] Unexpected error: Invalid handle (EUNKNOWN) (path: \path\that\no\longer\exists)
... [error] [File Watcher (parcel)] restarting watcher after error: Invalid handle
Hopefully viewing this log helps you find out what's breaking in your specific case.
I also encountered this problem. I was using VSCode and opening a folder in it on WSL Ubuntu 20.04. The solution for me was to install the VS Code Remote - WSL extension.
I hope this will be useful for someone.
TLDR : on Windows 10, if you have Cygwin64 installed and you got a Git For Windows update, check Git for Windows path comes before Git from Cygwin path in environment variables.
Long version : Just got into the same error today. The Git Lens extension was not working anymore.
I'm on Win 10, so there is no way (at least I didn't find one) to increase the limit of watchers like on linux. My VS Code is v1.66.2, Git Lens extension is v12.0.6.
In my case, the logs said :
... [error] [File Watcher (parcel)] Unexpected error: Invalid handle (EUNKNOWN) (path: cygwin\g\path\that\exists)
Notice that ENOSPC !== EUNKNOWN
So I searched everywhere with little to no success, except here where Gordon Christopher Weeks's answer actually hinted me towards that logs.
Then I remembered several things :
I have a terminal installed that's called cygwin64 and that allows me to use some linux utilities otherwise not available on Win (like rsync);
two days ago, I authorized an update for Git for Windows (2.35.2);
when I installed cygwin, the tutorial I followed told me about following a certain sequence in the Windows path environment variable
So I checked the path variable, noticed the Git update deleted the initial path to git and put it in the last place. I only had to move it up, before the cygwin64 path to git.exe (a git utility is included with cygwin) and everything's back to normal.
Hope this helps and so you won't waste the time I did !
[Possible quick solution] First thing to check is to see if you are tracking a WSL folder in a Visual Studio Code Explorer workspace AND you switched VS Code back to windows (was in a WSL distro).
If so, then right-clicking on it and selecting "remove from workspace" will also remove it from the file change watcher.
Refresh the file change watcher (bell icon, lower right corner of window) to see if it cleans up the problem.
This was the issue I had with the system.

VSCode keeps opening powershell on start even though Git Bash is set as default

I have set my integrated default terminal in VSCode as Git Bash but whenever I launch VSCode, powershell pops up instead of bash. It does not, however, change the default terminal setting but it is irritating.
I have tried removing the profile of powershell from settings but that seems to do nothing.
Why is this happening?
Make sure you upgrade to vscode v1.60.1 - there is a fix in that point release for this issue.
See Select Default Profile do not actually open gitbash. After relaunch, on startup, it just keeps open PowerShell.
The same thing was happening to me and the referred to fix in the Insiders' Build 05/14/2021 did in fact fix it for me. In the meantime, opening another terminal does always open git bash for me - but that is a pain.
This worked for me:
{
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.integrated.profiles.windows": {
"PowerShell": null,
"Git Bash": {
"source": "Git Bash"
},
"Windows PowerShell": null
},
"terminal.integrated.automationShell.windows": "Git Bash",
"powershell.enableProfileLoading": false,
"powershell.integratedConsole.showOnStartup": false
}
I managed to find a workaround without using the Insider's Build that may work for some of you : I removed all profiles safe for the one I want, and reinstalled VS Code. Then it somehow started using the right terminal on startup. I don't know if this works without disabling all other profiles though.
I was still having this issue, and what worked for me was:
When PowerShell opened, I reset GitBash to my default, and then killed the terminal (so there were no terminal's running).
Removed the terminal panel from view by clicking the X in the top right
Closed VSCode
When I opened my codebase again and showed the terminal, it began working.
Just did an update to version 1.60.1
and it fixed it.
From the release notes the bug was addressed and has since been merged.
Update 1.60.1: The update addresses these issues
This looks like an ongoing issue that is still not fixed in the current version (1.60.0).
This is now fixed in my current version (1.61.1).

Latex file on vs code does not autocompile on save

I use the extension Latex Workshop, however my preview does not auto update on save. I have to run pdflatex each time.
I tried uninstalling and installing the extension, deleting the extensions file, and even reinstalled vs code. Yet, the same thing persists.
Is there a specific setting, etc that needs to be changed?
Strangely for me it only seems to work when configuring
latex-workshop.latex.autoBuild.run: "onSave"
As from here the setting for this is:
latex-workshop.latex.autoBuild.run
With value "onFileChange".
Note that this is the default value for this setting, so it should detect the changes automatically, but give it a try.
Local and ssh installation:
For me the problem was that I had Latex Workshop installed on SSH but not locally. After installing locally, the LaTEX icon showed up and also auto-compile on save worked right away.

VSCode Powershell integrated terminal hangs when starting

I am using VSCode version 1.12.2 in Windows 10 x64 build 16193. I am trying to debug Powershell in VSCode, but I cannot get the PowerShell Integrated Terminal working. Every time I started the terminal, here's what I see:
And then it hangs in that stage. I can still debug, start, step in, step out..., but I cannot view my variable or run any expression.
My VSCode is using powershell x64 here:
"terminal.integrated.shell.windows": "C:\\WINDOWS\\Sysnative\\WindowsPowerShell\\v1.0\\powershell.exe"
So this is a known issue with this version of windows 10. Workaround here: https://github.com/PowerShell/vscode-powershell/issues/742
It's possible it's getting stuck on something while loading your profile(s). Try adding this to your settings to skip this:
"powershell.enableProfileLoading": false
I have had a similar problem, it seems. I cannot be sure it is the same, but when I would "load a file with VSCode" (user installer confirmed, system installer unconfirmed), it would hang. The following avenues tested:
Double-clicking on a PS1 file (the association to Code being made)
Starting VsCode empty and then loading the file
Starting VsCode from the command-line with a file-designation parameter
Using the --verbose switch, I got a listing which lead me to believe that VsCode seemed to be checking on updates using NPM (I could be wrong here).
Whatever the underlying problem, I did a lot of prodding and probing, and the cure I found was this.
Delete the directory called C:\Users\YourUserId\.vscode.
This directory is rather large, is not wiped by software removal, and may be corrupted apparently. After deleting it, the problem disappeared.

How to prevent Visual Studio Code from always reopening the previous files or folders?

Visual Studio Code always seems to remember my session and reopen the files and/or projects that were open the last time I used it. It obviously behaves correctly when running it from the command line with a file or folder supplied, but when opening from a taskbar shortcut, I'd like it to default to an empty environment.
Is there any way to change this behavior?
You can also go into your settings and use the following:
"window.reopenFolders": "none"
which will not reopen the folders you were working on when you closed the editor. The other options are one (the default) and all.
Edit 2017-11-09:
The option is now changed in latest versions.
"window.restoreWindows": "none"
See Mathieu DOMER's answer.
Edit 2018-09-12:
Another setting related to this is the hotExit setting. This has been discussed in this answer to a related question. To prevent reopening and remembering unsaved files, you can set this to:
"files.hotExit": "off"
But from the test I've made, when the window.restoreWindows setting is set to none, this is not needed. I haven't tested every possible combination, so YMMV.
And to answer a question in the comments, to edit the settings, you have to open the settings file. Some documentation can be found here (at least on the date I am writing this).
Edit 2022-03-16:
If you prefer using a GUI to change the settings, see D'Arcy Rittich's answer.
In VS Code:
for Windows/Linux Ctrl+, (or choose File/Preferences/Settings) to open the settings page.
for Mac ⌘+, (or choose Code -> Preferences -> Settings) to open the settings page.
then type restoreWindows in the Search settings input to filter for this setting. Set it to none and restart VS Code.
With latest update, it seems that the parameter has changed, now use:
"window.restoreWindows": "none"
You can add the -n option to the startup of VS Code and it will always start with an empty window, not restoring your previous session.
01 December 2018
This works for me. i.e. "C:\Users\Sampath\AppData\Local\Programs\Microsoft VS Code\Code.exe" -n
For me, none of above is working while I'm trying to close "dirty" unsaved files which I accidentally edited 1000 files and wanted to ignore saving all of them.
My fix was adding this line into settings.json:
"files.hotExit": "off"
Open up vscode, close vscode and just click the confirmation button to close all of the files without saving.
Then open back vscode and boom.. no more unsaved files being shown.
If "window.restoreWindows": "none" not solve the problem,then try to run code as root -> sudo code --user-data-dir code files and restart code normally without root.
Below worked for me
Right-click on Shortcut and add --disable-gpu to Target as per screen shot.
For me the only solution that worked was to go to the solution root and delete the .vs folder.
I reinstalled Visual Studio Code by downloading the latest update. I did not have to uninstall the previously installed Code. It work ok for me now.