刘勇虎的官方网站
网站内容包含大前端、服务器开发、Python开发、iOS开发、Android开发、网站维护等技术文章。专注于分享技术经验,职业心得体会,IT优秀文章与教程创作。
Stay hungry,Stay foolish,Stay young
VSCode中的Integrated Terminal的行为始终与普通终端有些不同,尤其是在Linux和macOS上。原因是环境始终是从VSCode的窗口(实例)继承的,并且VS VS /电子相关的环境变量已删除,而通常会从Dock / Start菜单中启动普通终端并使用系统环境。在某些情况下这可能会导致问题,例如Python虚拟环境由于使用$PATH
变量的方式而损坏。
有一个新的预览选项,terminal.integrated.inheritEnv
当false
时,终端不使用VS Code的环境。
而是,取决于平台,它将执行以下操作:
设置inheritEnv
为的主要可见结果false
是$SHLVL
(shell级别)现在应该为1,并且$PATH
不应包含重复路径,前提是启动脚本没有故意包含它们。
为默认值terminal.integrated.inheritEnv
是true
,这是以前的行为,但VSCode可能在未来会值切换到false
。
The Integrated Terminal in VS Code has always acted a little differently to normal terminals, particularly on Linux and macOS. The reason is that the environment was always inherited from VS Code’s window (instance) and VS Code/Electron-related environment variables were removed, whereas a normal terminal would typically be launched from the Dock/Start menu and use the system environment. This could cause issues in certain scenarios, for example Python virtual environments were broken because of how they use the
$PATH
variable.
There’s a new preview option,terminal.integrated.inheritEnv
, that whenfalse
causes the terminal to not use VS Code’s environment.
Instead, depending on the platform, it will do the following:
- Linux : Fetch and use the environment of the parent process of VS Code’s “main process”.
- macOS : Pull a handful of important environment variables off the current environment and only include them. Eventually we would like macOS to behave the same as Linux but there are currently issues with fetching environments.
- Windows : Currently this setting does not affect Windows.
The main visible result of settinginheritEnv
tofalse
is that$SHLVL
(shell level) should now be 1 and$PATH
should not include duplicate paths, provided your launch scripts don’t intentionally include them.
The default value forterminal.integrated.inheritEnv
istrue
, which is the previous behavior, but we will probably switch the value tofalse
in the future.