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

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

Related

VSCode: "Shell Integration failed to activate"

It used to work fine, but recently whenever I run my code (Python), I get the message "Shell Integration failed to activate" when I hover my mouse over the active terminal. The active Python terminal doesn't recognize any command line commands like "pip" anymore (see screenshot)
What can I do? I played around with a couple of settings as described here, but nothing seems to work. My current setting.json file looks like this:
{
"python.defaultInterpreterPath": "C:\\Users\\cleme\\AppData\\Local\\Programs\\Python\\Python310\\python.exe",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"path": "C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
"source": "PowerShell",
"icon": "terminal-powershell",
}
},
"terminal.integrated.defaultProfile.windows": "PowerShell"
}
I ended up deleting the whole Code folder within the C:\Users\AppData\Roaming.
Note: You have to check the box - view Hidden Files to see these folders within File Explorer.
This solved it.
There must have been some weird corrupted cache issue at the heart of this.
I found this in C:\Users<profile>\AppData\Roaming\Code\logs<datetimestamp>\ptyhost.log
[2022-10-17 07:25:50.695] [ptyhost] [warning] Couldn't get layout info, a terminal was probably disconnected Could not find pty on pty host
[2022-10-17 07:25:54.040] [ptyhost] [warning] Shell integration cannot be enabled for executable "C:\Windows\System32\cmd.exe" and args []
[2022-10-17 07:26:57.939] [ptyhost] [warning] Shell integration cannot be enabled for executable "C:\Windows\System32\cmd.exe" and args []
I think it is related to this.
BTW: I had tried adding a couple of PowerShell VSCode IDE Extensions when things went awry.
IIRC they were:
PowerShell
PowerShell Preview
I had upgraded PowerShell to the latest version 7 too.
$PSVersionTable yielded the following from the respective executables.
Executable Path
Version
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
5.1.17763.1852
C:\Program Files\PowerShell\7\pwsh.exe
7.2.6
Maybe that combo hosed things
Follow up note: Whilst it seemed to have fixed the issue once... soon after the problem manifested itself again. This time I couldn't reset VS Code to a working environment.
Then I realised had opened the Project folder in the explorer on the left of the IDE.
I had a subfolder that had a PS1 file within that.
It didn't have its own .vscode\settings.json
When I copied it down from the parent folder, suddenly everything worked again.
.vscode\settings.json just contained this:
{
}
Again this ended up being a one time solution.
I ended up back at:
Shell activation failed to activate for cmd.exe
I posted this as a new ticket here
In the end I found this to be more of a display issue than anything else!
You can actually type cls then hit ENTER, to restore things to the status quo.
The Terminal section is black with no prompt to begin with. But you can type in it!!!
Perhaps the Prompt is black text on a black background initally, since when you start typing cls, it's quite a way to the right of the left margin.
Closing VSCode, verifying that powershell works, then reopening it worked for me.

Git bash is installed and integrated but I don't see it in the terminal list of vs code

All other terminals are visible enter image description herein the list like command prompt, etc. But, Git bash is not showing up. I am worried If I have installed and integrated Git properly. I am sharing the settings.json. Please, let me know where I am wrong or I can share more info
Open you settings.json file and add the following at last.
"terminal.integrated.profiles.windows":{"GIT BASH ADDED ":{"path":"C:\\Program Files\\Git\\git-bash.exe"}, },
"terminal.integrated.defaultProfile.windows": "Git Bash"
Remember to add the path of your git-bash.exe correctly (wherever you have installed it).
see the screenshot for you reference.

my terminal inserts and enters the letter "Y" after most git commands

Myself and a coworker have started experiencing an odd issue where the "Y" character is inserted and then entered after nearly every git command. (Git add. , git commit, git push etc)
I am using Visual studio and typing my commands in the terminal window.
This issue does not break any functionality, it's just weird and very hard to google.
Probably because of the new setting:
Terminal > Integrated: Auto Replies
see v1.64 Release Notes
Do you have anything in this setting: "terminal.integrated.autoReplies"?
The feature is supposed to be opt-in so it shouldn't be doing that unless you have something in that setting. Unless there is a git extension that is doing that "for you". You could look through any git extension settings you may have installed to see if they enable an auto replies feature - I don't think the built-in git extension does.
In your case if you don't have a "terminal.integrated.autoReplies" that looks like a bug to me.
Even I had this similar issue with the vscode terminal in windows. Its kinda irritating when it keeps adding that "Y" after git commands automatically. (I did not turn on the feature. This is the default behaviour)
Add this to your vscode settings.json file and it should get disabled.
"terminal.integrated.autoReplies": {
"Terminate batch job (Y/N)": null }

VSCode: set terminal shell on workspaces after latest update

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

VS Code opens a new debug console every time I build/run

Every time I build or run a program in VSCode a new python debug console is loaded. Before I know it I have 20+ and need to start deleting them. After 32 open consoles I get the error "The terminal process terminated with exit code: 256". I changed the terminal from the default console to git bash recently. How can I stop this?
A way around this issue is to stop VS Code from redundantly printing to the TERMINAL during debugging in the first place. Since it prints to the DEBUG CONSOLE as well, you can use that instead.
Change console to "none" "internalConsole" in each configuration in your project's launch.json file:
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "internalConsole"
}
]
May 2019 Update: the "none" option was replaced by "internalConsole" so I edited my answer to reflect that. Here's the relevant GitHub Issue.
Adding "args": ["&&", "exit"], to launch.json remedies this for Git Bash. Certainly a hack, but I no longer have to manually close many debug terminals.
This may have been resolved in recent debug updates to core VS Code within the last year (as of 8/2022), but I was still seeing this intermittently.
I don't know if this will help the original poster, but I discovered that for me the issue persisted due to using Git Bash as the default terminal in Windows. Switching to Command Prompt as the default terminal fixed the issue. I haven't tested with other platforms or terminals.
Changing the default terminal to Command Prompt causes the Python extension to launch the "Python Debug" terminal with Command Prompt instead of Git Bash. I did log a VS Code/Python Extension defect about this. The initial response is that Git Bash is not officially supported currently.
There appears to be a communication problem between the Git Bash terminals and VS Code that causes this issue. Some of the characters between Git Bash and VS Code get dropped. Sometimes this mangles the debug command and I get and error and have to retry in addition to getting an extra debug window.
There is some additional background info and hacks to fix this from the past in this answer.
Hopefully fixed in the Insiders Build and should be in v1.54. See Debug opens a new integrated terminal for each Python session
. Test it in the Insiders Build if you can and report at the issue if it fixed/did not fix.
Actually you can delete all the instances of the terminal just by clicking on the trash can icon 🗑. If it does not work for the first time, restart the VS Code and try again.