VSCode default Integrated Terminal is not changing - visual-studio-code

I'm using VSCode for some time now and until today the Terminal was working as expected.
But now I can't change the default Integrated Terminal. It's allways "cmd" no matter what I set up in the settings.
The settings.json seems to be fine:
{
"window.zoomLevel": -1,
"files.associations": {
"*.testset": "feature"
},
"git.autofetch": true,
"C_Cpp.updateChannel": "Insiders",
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
}
But every new terminal is still "cmd".
Not "bash" or "PS".

The issue was in my workspace settings.
"project.code-workspace"
{
....
"settings": {
"terminal.integrated.shell.windows": "cmd.exe"
}
}
By removing this line from the file, the problem was fixed. Now I can change the default Integrated Terminal.

most of the time this issue happens when new updates come,
the easiest ways to solve this is:
https://youtu.be/jpwfr6m50sI - here you will see how to change the default terminal
uninstall your vscode install the previous one (if you don't know how to do this, follow this: How to downgrade vscode )
Dont hesitate to report to GitHub of vscode team as well as follow
their documentaries

Related

How to fix Code not displaying anaconda prompt as Terminal?

The Python interpreter is working fine and is fully configured. So it should be using the anaconda prompt by default for the Terminal. However this has not been the case so I tried setting up manually. This is what I've set so far:
This is the prompt when I hover over 'terminal.inegrated.defaultProfile.windowss" value:
Also 'Anaconda Shell' is not selectable from the dropdown for the Terminal sub-window. It doesn't show there but the rest are being displayed:
Is there a away to actually override Code to recognise the anaconda prompt to be set as default?
You need to configure it like this:
"Anaconda": {
"path": "cmd.exe",
"args": ["/K", "C:\\ProgramData\\Anaconda3\\Scripts\\activate.bat"]
}

VSCode is suddenly defaulting to powershell for integrated terminal and tasks

When I woke up this morning and launched VSCode my default terminal on launch, and when running tasks is now powershell, instead of Git Bash. I am on windows. I have tried changing the settings.json to no avail. Is there something I'm missing?
{
"workbench.startupEditor": "newUntitledFile",
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"[javascript]": {
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
},
"aws.samcli.location": "C:\\Users\\king\\AppData\\Roaming\\npm\\sam.exe",
"typescript.updateImportsOnFileMove.enabled": "always",
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"javascript.updateImportsOnFileMove.enabled": "always",
"explorer.confirmDragAndDrop": false,
"diffEditor.maxComputationTime": 0,
"extensions.ignoreRecommendations": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.renderControlCharacters": true,
"[jsonc]": {
"editor.quickSuggestions": {
"strings": true
},
"editor.suggest.insertMode": "replace"
},
"window.zoomLevel": 0,
"editor.accessibilitySupport": "off",
"workbench.editor.untitled.hint": "hidden",
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.external.windowsExec": "C:\\Program Files\\Git\\bin\\bash.exe",
"terminal.explorerKind": "external",
"terminal.integrated.automationShell.linux": ""
}
I found this related SO post making the default powershell, but I didn't see anything that was incorrect about my setting...especially because my goal is the opposite- to stop Powershell!
Update: Version v1.60.0 had a bug. Upgrade to v1.60.1 or higher for a fix.
The bug manifested in the following symptoms:
The Open in Integrated Terminal shortcut-menu command in the Explorer pane's shortcut always uses the built-in default shell (PowerShell on Windows), ignoring the configured one.
The same goes for running tasks (with or without a separate terminal.integrated.automationShell.* setting).
Also, if a given folder or workspace happened to have an integrated terminal open when quitting Visual Studio Code, the shell that is launched when the integrated terminal automatically reopens the next time is again the built-in default shell, not the configured one. By contrast, if reopening doesn't auto-open the integrated terminal, opening it manually does respect the configured default shell, and so does manually creating another shell instance later.
See GitHub issue #132150
The following information turned out to be unrelated to the bug, but is hopefully still useful general information about Visual Studio Code's recent change in how shells for the integrated terminal are configured:
Migrating from the legacy default shell settings to shell profiles:
Recently, the "terminal.integrated.shell.*" and "terminal.integrated.shellArgs.*" settings were deprecated and replaced with a more flexible model that allows defining multiple shells to select from, via so-called shell profiles, optionally defined in setting "terminal.integrated.profiles.*", with an associated mandatory "terminal.integrated.defaultProfile.*" setting referencing the name of the profile to use by default - which may be an explicitly defined custom profile or one of the built-in, platform-appropriate default profiles.
Note: * in the setting names above represents the appropriate platform identifier, namely windows, linux, or osx (macOS).
As of v1.60.1, if legacy "terminal.integrated.shell.*" settings are also present, the new settings take precedence (even though the tooltip when editing "terminal.integrated.shell.*" in settings.json suggests that this change is yet to come).
In the absence of both settings, Visual Studio Code's built-in default shell is used, which on Windows is PowerShell,[1] and on Unix-like platforms the user's default shell, as specified in the SHELL environment variable.
Recent Visual Studio Code versions, starting before v1.60 - seemingly as one-time opportunity - displayed a prompt offering to migrate the deprecated settings to the new ones.
Accepting the migration results in the following:
Creation of setting "terminal.integrated.shell.*" containing a custom shell profile derived from the values of legacy settings "terminal.integrated.shell.*" and, if present, "terminal.integrated.shellArgs.*"; that custom profile's name has the suffix (migrated)
Creation of setting terminal.integrated.defaultProfile.* whose value is the migrated profile's name, making it the default shell.
Removal of legacy settings "terminal.integrated.shell.*" and "terminal.integrated.shellArgs.*"
If you decline the migration, you can later effectively perform it by re-choosing the default shell, as described below.
Note: The new "terminal.integrated.defaultProfile.*" setting that is created in the process then effectively overrides the legacy "terminal.integrated.shell.*" and "terminal.integrated.shellArgs.*" settings, but the latter won't be removed automatically. To avoid confusion, it's best to remove them from settings.json manually.
Choose the default shell profile to use in order to (re)specify the default shell:
Click on the down-arrow part of the shell-selector icon () on the right side of the integrated terminal, select Select Default Profile, which presents a list of the defined profiles to select the default from - in the absence of explicitly defined profiles, standard profiles are offered (see below).
This translates into a terminal.integrated.defaultProfile.* setting in settings.json, whose value is the name of the chosen shell profile - which may be the name of a built-in profile or one of the ones explicitly defined in "terminal.integrated.profiles.*"
Note: This shell is by default also used for tasks (defined in tasks.json), but that can be overridden with a "terminal.integrated.automationShell.*" setting pointing to the executable of an alternative shell.
Optionally, in your settings.json file, you may create a platform-appropriate terminal.integrated.profiles.* setting with shell profiles of interest:
Note: Even if your settings.json contains no (platform-appropriate) "terminal.integrated.profiles.*" setting, Visual Studio code has built-in standard profiles it knows of and offers them for selection when choosing the default shell.
These standard profiles are a mix of shells that come with the host platform as well as some that Visual Studio detects dynamically on a given system, such as Git Bash on Windows.
To create the standard profiles explicitly, do the following:
Note: You may choose to do this in order to customize the standard profiles. However, if your intent is merely to add custom profiles - see this answer for an example - it isn't necessary to create the standard profiles inside the "terminal.integrated.profiles.*" setting, because Visual Studio Code knows about them even if not explicitly defined.
Via File > Preferences > Settings (Ctrl-,), search for profiles and click on Edit in settings.json below the platform-appropriate Terminal > Integrated > Profiles > * setting; this will open settings.json for editing, with the standard profiles added; simply saving the file is sufficient.
Note: If the "terminal.integrated.profiles.*" setting shown doesn't contain the expected, platform-appropriate standard profiles, a setting by that name may already be present; to force creation of the standard profiles, remove or comment out the existing setting and save the file, then try again.
On Windows, you'll end up with something like the following:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
}
}
The answer you link to in your question, which provides an overview of the various types of shells used in Visual Studio Code, has been updated to reflect the information about the new shell profiles.
[1] Note: If a PowerShell (Core) v6+ installation is found, it takes precedence over the built-in Windows PowerShell version.
Edit:1
Note: Now this bug has been fixed by VSCode. Just update your VSCode to the latest version. (17-Sep-2021)
I have a temporary solution.
First paste this code in settings.json and save
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.integrated.profiles.windows": {
"C:\\Program Files\\Git\\bin\\bash.exe": {
"path": "",
"args": []
}
},
Before closing VSCode select Output instead of Terminal
Now you can open VSCode
After VSCode is loaded, you need to click on Terminal. After this you will now see bash.
Select output before whenever you close VSCode.
Reference: VSCode is suddenly defaulting to PowerShell for integrated terminal instead of $Bash in Windows
Note: This is not an solution. I shared this because maybe it can save you from getting disappointed.
This is my first post, if there is any mistake please let me know so that I can correct it.
You can always download and install previous releases from the official website https://code.visualstudio.com/updates/v1_59 (currently at the top).
As version 1.60 was bugged, v1.59 is a good candidate.
Disable automatic updates
Explained here.
Open User Settings File > Preferences > Settings.
Add "update.mode": "none" to your settings.
Install older version
Afterwards you can just overwrite current version with the installation of downloaded version.
Note: Wait for next version to fix it, so remember you had automatic update disabled!
I have same problem but I try run command prompt. I fix it by adding to ...\Code\User\settings.json
"terminal.integrated.automationShell.windows": "cmd.exe",
This could be related to issue 138999 which will add a mitigation/enhancement to VSCode 1.70 (July 2022) with PR 154290 and commit 91b82c0
increase barrier for available profiles to be ready
Wait up to 20 seconds for profiles to be ready so it's assured that we know the actual default terminal before launching the first terminal.
This isn't expected to ever take this long.
For VSCode with synchronized user settings, the profile might take more time than expected to fully load, hence the advantage of that workaround.
Simply replaced the CMD by Git Bash :-) in the settings.json
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
//"${env:windir}\\Sysnative\\cmd.exe",
//"${env:windir}\\System32\\cmd.exe"
"C:\\PrivateProgramms\\Git\\bin\\bash.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
//"path": [ "C:\\PrivateProgramms\\Git\\bin\\bash.exe" ],
//"args": [],
//"icon": "terminal-cmd"
}
},
"terminal.integrated.defaultProfile.windows": "Command Prompt"

Visual Studio Code WSL Remote - WSL Terminal Ignoring Cwd

I have read several other forums and posts about setting the default directory when opening a new integrated terminal session to no avail.
When I first start using VSC it seems to open the workspace directory for the first couple days. But it must have synched my settings from a previous install and brought back something that I could never figure out on my previous windows install. For some reason when it opens a terminal it opens to the AppData folder location for Microsoft VS Code as shown below:
<user>#<hostname>:/mnt/c/Users/<user>/AppData/Local/Programs/Microsoft VS Code$
If for instance I go into File > Preferences > Settings and try adding $HOME or ${HOME} I get:
The terminal process failed to launch: STarting directory (cwd)
"/home/<user>/${HOME}" does not exist.
or
The terminal process failed to launch: Starting directory (cwd)
"/home/<user>/$HOME" does not exist.
After doing this if I delete the information in Cwd then I receive the error that:
Setting has an invalid type, expect "string". Fix in JSON.
I can fix this by changing the setting to:
"terminal.integrated.cwd": "."
My user profile is basically default:
{
"workbench.editorAssociations": [
{
"viewType": "jupyter.notebook.ipynb",
"filenamePattern": "*.ipynb"
}
],
"git.autofetch": true,
"workbench.colorTheme": "One Dark Pro",
"python.languageServer": "Pylance",
"terminal.integrated.scrollback": 10000,
"terminal.integrated.tabs.enabled": true,
"terminal.integrated.tabs.location": "left",
"terminal.integrated.bellDuration": 10000,
"terminal.integrated.cwd": "."
}
There are only a few settings I changed like tab location and scrollback value.
Any thoughts?
Re-install and newer versions of WSL seemed to be the only fix for this.

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

How do I get around the verified bug in Windows 1903 and launch the VSCode integrated terminal?

I just did a fresh install of Windows 10 Pro version 1903 build 18362.116 and Visual Studio Code. Now the integrated terminal only launches externally.
Pressing Ctrl + ~ results in this.
What am I missing? How do I get it to open integrated again?
EDIT
After working with VSCode team it is a verified bug. See the Github issue here. I posted the workaround as an answer here.
OK, worked through this one in VSCode repo issues.
For now, until it's fixed, turn off ConPTY integration in the User Settings.
💥💥💥
The issue now says use legacy console. To change the setting open a cmd prompt. Right click the title to bring up properties.
Then Uncheck 'Use legacy console'
To change the integrated terminal on Windows, you just need to change the terminal.integrated.shell.windows line:
Open VS User Settings (Preferences > User Settings). This will open two side-by-side documents.
Check if "terminal.integrated.shell.windows" has value "C:\\Bin\\Cmder\\Cmder.exe" setting to the User Settings document on the right.
Remove this line.
Ctrl + ~ will now open integrated terminal of VSCode.
If the above solution doesn't work then can you try below values and check if it works for you:
// Command Prompt
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"
// PowerShell
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
// Git Bash
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe"
// Bash on Ubuntu (on Windows)
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe"
From the Command Palette (Ctrl+Shift+P), use the View: Toggle Integrated Terminal command.
Try custom shortcut:
[
{
"key": "ctrl+`",
"command": "workbench.action.terminal.toggleTerminal"
}
]
Had this problem fixed. Found the solution from the VS Code support.
for error:
Terminal exits with code 3221225786 (or similar)#
"This can happen when you have legacy console mode enabled in conhost's properties. To change this, open cmd.exe from the start menu, right-click the title bar, go to Properties and under the Options tab, uncheck Use legacy console."
source: VS Code docs