vscode shell設置 升級到1.56版后終端配置不支持"terminal.integrated.shell.windows"后的解決辦法


我用 vs code 開發ESP8266固件,一直用make flash用的好好的,今天打開發現命令不能執行了,想起昨天升級過vscode,就查了下setting.json,發現有如下提示:

終端在 Windows 上使用的 shell 的路徑(默認: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe)。詳細了解如何配置 shell。

This is deprecated, the new recommended way to configure your default shell is by creating a terminal profile in `#terminal.integrated.profiles.osx#` 
and setting its profile name as the default in `#terminal.integrated.defaultProfile.osx#`. This will currently take priority over the new profiles
settings but that will change in the future.(2)

意思是原來的terminal.integrated.shell.windows配置方式已經不再支持, 要修改文件路徑: .vscode\settings.json

    "terminal.integrated.shell.windows": "xx/ESP/msys32/msys2_shell.cmd",  //不支持的配置 "terminal.integrated.shellArgs.windows": [
        "-defterm",
        "-mingw32",
        "-no-start",
        "-here"
    ],
    "terminal.integrated.env.windows": {
      "CHERE_INVOKING": "1",
      "MSYSTEM": "MINGW32"
    }

解決方法:

經過搜索后,配置修改為如下配置:

"terminal.integrated.profiles.windows": {    //新的配置 "MINGW32": {
        "path": "xx/ESP/msys32/msys2_shell.cmd",   //shell路徑     
        "icon": "terminal-cmd",
        "args": [
          "-defterm",
          "-mingw32",
          "-no-start",
          "-here"],
          "env": {
            "CHERE_INVOKING": "1",
            "MSYSTEM": "MINGW32"
          }
      }
    },    

然后重新打開vs code,我去,竟然還是默認的power shell, 這是咋回事呢?

vs code中首選項中,搜索@feature:terminal,看到用戶配置下面的 Allow workspace configuration沒有打勾,於是勾上,重新打開vs code, 熟悉的界面又回來了。

 

 make命令又可以正常使用了。

 

補充:

 VScode升級到1.57.1后又提示要轉換新的環境,點遷移后正常,沒有發現問題。以下為項目級(路徑:項目文件夾下的.vscode/settings.json中)配置: 

"terminal.integrated.defaultProfile.windows": "Command Prompt"  //設置本工作區的默認終端,用於覆蓋系統的默認設置,這樣打開工作區,就默認打開了需要的終端

  

用戶級settings.json,可以通過打開菜單:文件>首選項>設置,然后搜索terminal, 點擊 在settings.json中編輯即可看到所有現有終端的配置

 

以下為配置實例放在在項目文件夾下.vscode\settings.json中,僅影響當前項目:

    "terminal.integrated.profiles.windows": {      //新的配置
      "ESP32C3": {
        "path": "${env:windir}/System32/cmd.exe",   //shell路徑     
        "icon": "terminal-cmd",
        "args": [
          "/k",
          "xx/.espressif/idf_cmd_init.bat",
          "esp-idf-402269c78bff9d18",
          "-noexit",
          "-here"],
        "overrideName": true, //是否用Profile的名字來替代默認檢測到的名字,這里是ESP32C3替代cmd
      }
    },
    "terminal.integrated.defaultProfile.windows": "ESP32C3" //默認的終端配置

 

參考:

https://code.visualstudio.com/docs/editor/integrated-terminal


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM