VScode 终端的 PATH 环境变量与 cmd 不同

问题描述

当我在 vscode 的终端中运行 chatSocket.onopen = function(e) { chatSocket.send(JSON.stringify({ 'command': 'fetch_messages' })) } chatSocket.onmessage = function(e) { const data = JSON.parse(e.data); if (data.length > 1) { for (let i = 0; i<data.length; i++) { createMessageDiv(data[i],username) } } createMessageDiv(data,username) }; function createMessageDiv(data,username) { let div = document.createElement('div'); div.classList.add('message'); if (data['username'] == username) { div.classList.add('from-me'); }; text = document.createTextNode(data["message"]); div.appendChild(text); document.querySelector('#chat-log').prepend(div); return div; } 时,结果是:

echo %Path%

但是当我在命令行(cmd.exe)中运行它时,结果是:

C:\Users\user\.platformio\penv\Scripts;C:\Users\user\.platformio\penv;C:\Users\user\.platformio\python3;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\NAT Service;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files....

这与我在 vscode 中得到的不同。 我尝试打开和关闭继承 env,重新启动 vscode,然后重新启动我的计算机,但没有任何变化。

如何使 vscode 中的 %Path% 与 cmd.exe 中的相同?

我当前的 vscode 设置是:

C:\Program Files\AdoptOpenJDK\jdk-8.0.292.10-hotspot\bin;C:\Program Files\AdoptOpenJDK\jdk-16.0.1.9-hotspot\bin;C:\Program Files (x86)\NAT Service;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerSh...

用于用户设置和

{
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe","terminal.external.windowsExec": "C:\\Windows\\System32\\cmd.exe","window.zoomLevel": 0,"editor.suggestSelection": "first","vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue","java.configuration.checkProjectSettingsExclusions": false,"java.errors.incompleteClasspath.severity": "ignore","java.project.importOnFirstTimeStartup": "automatic","terminal.integrated.tabs.enabled": true,"files.autoSave": "afterDelay","workbench.colorTheme": "Default Dark+","java.configuration.runtimes": [
    {
        "name": "JavaSE-16","path": "C:\\Program Files\\AdoptOpenJDK\\jdk-16.0.1.9-hotspot","default": true
    },{
        "name": "JavaSE-1.8","path": "C:\\Program Files\\AdoptOpenJDK\\jdk-8.0.292.10-hotspot"
    },],"java.home": "C:\\Program Files\\AdoptOpenJDK\\jdk-16.0.1.9-hotspot",}

用于工作区设置

解决方法

我重新安装了 PlatformIO 扩展并修复了它。 PlatformIO 自带的自定义路径变量选项一定有问题