You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
do not always launch integrated terminal's shell as a login shell #50340
macosIssues with VS Code on MAC/OS XterminalGeneral terminal issues that don't fall under another labelunder-discussionIssue is under discussion for relevance, priority, approach
On macOS VS Code's integrated terminal by default uses bash with a -l option which means:
Make bash act as if it had been invoked as a login shell
This means that bash for a newly created integrated terminal will always try to read ~/.bash_profile, ~/.bash_login, and ~/.profile.
IMO passing -l is a bad idea for (at least) the following reasons:
if VS Code is launched from a terminal where the user has set specific environment variables, VS Code tries hard to preserve these environment variables for the workspace so that a subsequent integrated terminal (or task or debug session) inherits these environment variables. By using the -l option this effort is negated because bash reads ~/.bash_profile, ~/.bash_login, and ~/.profile which might reset the carefully established environment.
if a different shell is configured via the terminal.integrated.shell.osx (e.g. PowerShell), the user is not aware that the -l is passed and PowerShell fails with a strange error message.
Ideally -l should only be used if VS Code was not launched from a terminal (because that would be more in line with how Terminal.app or iTerm.app behave on macOS).
This might require a new settings attribute loginShellArgs that is only used if the shell is started as a login-shell. However, this does not address the second problem from above.
This is a tricky subject and I frequently still get issues reported around this. A common one is this which is caused by running a login shell from within a login shell (due to the way we get the environment when not launched from a terminal:
You can repro the problem in external terminals by running bash -l inside a login shell where the .bash_profile is not idempotent.
I believe the inverse will also cause problems though because I was still getting issues around it before I changed it, here's a bit of history on the issue:
One problem that will probably occur is people will lose their aliases because they set them up in .bash_profile which is run on launch by the shell in external terminals, but they would be lost if VS Code launches the login shell and the terminal launches a non-login shell.
I was just about to file a bug report. Because it is impossible to remove that option from the default behavior, and it is not possible to specify an empty string in settings.json, the user has to manually configure a workable option (e.g. -Interactive for Powershell Core) which will override the default -l.
But the bug does break the usability of PowerShell Core in the integrated terminal out of the box, an odd decision for Microsoft devs to make.
macosIssues with VS Code on MAC/OS XterminalGeneral terminal issues that don't fall under another labelunder-discussionIssue is under discussion for relevance, priority, approach
Activity
Tyriar commentedon May 23, 2018
This is a tricky subject and I frequently still get issues reported around this. A common one is this which is caused by running a login shell from within a login shell (due to the way we get the environment when not launched from a terminal:
https://code.visualstudio.com/docs/editor/integrated-terminal#_why-is-nvm-complaining-about-a-prefix-option-when-the-integrated-terminal-is-launched
You can repro the problem in external terminals by running
bash -linside a login shell where the.bash_profileis not idempotent.I believe the inverse will also cause problems though because I was still getting issues around it before I changed it, here's a bit of history on the issue:
["-l"]the default for the.osxsetting Default Configuration Change: Integrated Terminal Defaults OSX/Linux #20145 (comment)One problem that will probably occur is people will lose their aliases because they set them up in
.bash_profilewhich is run on launch by the shell in external terminals, but they would be lost if VS Code launches the login shell and the terminal launches a non-login shell.jasper-zanjani commentedon Jul 4, 2019
I was just about to file a bug report. Because it is impossible to remove that option from the default behavior, and it is not possible to specify an empty string in settings.json, the user has to manually configure a workable option (e.g.
-Interactivefor Powershell Core) which will override the default-l.But the bug does break the usability of PowerShell Core in the integrated terminal out of the box, an odd decision for Microsoft devs to make.
Tyriar commentedon Jul 4, 2019
The solution for this is captured in #70248 (windows deferred to #47816)