0

When running my c++ code using code runner extension in vscode, the terminal switches to powershell even though the, "terminal.integrated.defaultProfile.windows" is set to Ubuntu-20.04 (WSL). This messes up my execution statement which is for linux based environments.

I have tried :

  1. Removing powershell profiles from "terminal.integrated.profiles.windows"
  2. Using the legacy "terminal.integrated.shell.windows" and setting it the C:\\Windows\\System32\\wsl.exe

Here is my settings.json file

{
    "editor.mouseWheelZoom": true,
    "code-runner.clearPreviousOutput": true,
    "explorer.confirmDelete": false,
    "workbench.colorTheme": "Atom One Dark",
    "workbench.iconTheme": "material-icon-theme",
    "color-highlight.markerType": "foreground",
    "files.associations": {
        "*.html": "html",
    },
    "editor.formatOnSave": true,
    "prettier.spaceBeforeFunctionParen": true,
    "latex-workshop.view.pdf.viewer": "browser",
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "python.jediEnabled": false,
    "[cpp]": {
        "editor.defaultFormatter": "ms-vscode.cpptools"
    },
    "debug.allowBreakpointsEverywhere": true,
    "debug.showBreakpointsInOverviewRuler": true,
    "C_Cpp.updateChannel": "Insiders",
    "liveServer.settings.donotShowInfoMsg": true,
    "code-runner.runInTerminal": true,
    "code-runner.saveFileBeforeRun": true,
    "workbench.editor.enablePreview": false,
    "workbench.colorCustomizations": {
        "activityBarBadge.background": "#C6FF00",
        "activityBar.activeBorder": "#C6FF00",
        "list.activeSelectionForeground": "#C6FF00",
        "list.inactiveSelectionForeground": "#C6FF00",
        "list.highlightForeground": "#C6FF00",
        "scrollbarSlider.activeBackground": "#C6FF0050",
        "editorSuggestWidget.highlightForeground": "#C6FF00",
        "textLink.foreground": "#C6FF00",
        "progressBar.background": "#C6FF00",
        "pickerGroup.foreground": "#C6FF00",
        "tab.activeBorder": "#C6FF00",
        "notificationLink.foreground": "#C6FF00",
        "editorWidget.resizeBorder": "#C6FF00",
        "editorWidget.border": "#C6FF00",
        "settings.modifiedItemIndicator": "#C6FF00",
        "settings.headerForeground": "#C6FF00",
        "panelTitle.activeBorder": "#C6FF00",
        "breadcrumb.activeSelectionForeground": "#C6FF00",
        "menu.selectionForeground": "#C6FF00",
        "menubar.selectionForeground": "#C6FF00",
        "editor.findMatchBorder": "#C6FF00",
        "selection.background": "#C6FF0040"
    },
    "materialTheme.accent": "Acid Lime",
    "prettier.alignObjectProperties": true,
    "window.zoomLevel": 0,
    "sync.gist": "d8dcbf95f71073eaaf5a5f900fcfd1b7",
    "explorer.confirmDragAndDrop": false,
    "editor.minimap.enabled": false,
    "explorer.openEditors.visible": 0,
    "workbench.startupEditor": "newUntitledFile",
    "terminal.integrated.fontFamily": "MesloLGS NF",
    "code-runner.executorMapByFileExtension": {
        ".vb": "cd $dir && vbc /nologo $fileName && $dir$fileNameWithoutExt",
        ".vbs": "cscript //Nologo",
        ".scala": "scala",
        ".jl": "julia",
        ".cr": "crystal",
        ".ml": "ocaml",
        ".exs": "elixir",
        ".hx": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
        ".rkt": "racket",
        ".scm": "csi -script",
        ".ahk": "autohotkey",
        ".au3": "autoit3",
        ".kt": "cd $dir && kotlinc $fileName -include-runtime -d $fileNameWithoutExt.jar && java -jar $fileNameWithoutExt.jar",
        ".kts": "kotlinc -script",
        ".dart": "dart",
        ".pas": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        ".pp": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        ".d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
        ".hs": "runhaskell",
        ".nim": "nim compile --verbosity:0 --hints:off --run",
        ".csproj": "dotnet run --project",
        ".fsproj": "dotnet run --project",
        ".lisp": "sbcl --script",
        ".kit": "kitc --run",
        ".v": "v run",
        ".vsh": "v run",
        ".sass": "sass --style expanded",
        ".cu": "cd $dir && nvcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
    },
    "code-runner.languageIdToFileExtensionMap": {
        "bat": ".bat",
        "powershell": ".ps1",
        "typescript": ".ts"
    },
    "code-runner.terminalRoot": "/mnt/",
    "code-runner.executorMap": {
        "javascript": "node",
        "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG && ./$fileNameWithoutExt",
        "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
        "php": "php",
        "python": "python -u",
        "perl": "perl",
        "perl6": "perl6",
        "ruby": "ruby",
        "go": "go run",
        "lua": "lua",
        "groovy": "groovy",
        "powershell": "powershell -ExecutionPolicy ByPass -File",
        "bat": "cmd /c",
        "shellscript": "bash",
        "fsharp": "fsi",
        "csharp": "scriptcs",
        "vbscript": "cscript //Nologo",
        "typescript": "ts-node",
        "coffeescript": "coffee",
        "scala": "scala",
        "swift": "swift",
        "julia": "julia",
        "crystal": "crystal",
        "ocaml": "ocaml",
        "r": "Rscript",
        "applescript": "osascript",
        "clojure": "lein exec",
        "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
        "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
        "racket": "racket",
        "scheme": "csi -script",
        "ahk": "autohotkey",
        "autoit": "autoit3",
        "dart": "dart",
        "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
        "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
        "haskell": "runhaskell",
        "nim": "nim compile --verbosity:0 --hints:off --run",
        "lisp": "sbcl --script",
        "kit": "kitc --run",
        "v": "v run",
        "sass": "sass --style expanded",
        "scss": "scss --style expanded",
        "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css"
    },
    "code-runner.customCommand": "cd $dir && g++ $fileName -o $fileNameWithoutExt -std=c++17 -Wshadow -Wall -O2 -Wno-unused-result && ./$fileNameWithoutExt",
    "[html]": {
        "editor.defaultFormatter": "vscode.html-language-features"
    },
    "python.languageServer": "Microsoft",
    "python.defaultInterpreterPath": "C:\\Users\\INVICTUS\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe",
    "prettier.singleQuote": true,
    "prettier.useTabs": true,
    "prettier.withNodeModules": true,
    "terminal.integrated.defaultProfile.windows": "Ubuntu-20.04 (WSL)",
    "terminal.integrated.profiles.windows": { 
        "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell"
        },
        "Command Prompt": {
            "path": [
                "${env:windir}\\Sysnative\\cmd.exe",
                "${env:windir}\\System32\\cmd.exe"
            ],
            "args": [],
            "icon": "terminal-cmd"
        },
        "Git Bash": {
            "source": "Git Bash"
        },
        "Ubuntu-20.04 (WSL)": {
            "path": "C:\\Windows\\System32\\wsl.exe",
            "args": [],
        },
        "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe (migrated)": {
            "path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
            "args": []
        },
        "Windows PowerShell": {
            "path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe"
        }
    },
    "code-runner.executorMapByGlob": {
        "pom.xml": "cd $dir && mvn clean package"
    }
}
  • I am almost willing to bet this is a side effect of https://stackoverflow.com/questions/69047142/vscode-is-suddenly-defaulting-to-powershell-for-integrated-terminal-and-tasks - in other words, it's a bug with the 1.60 release and should be patched soon. – Timothy G. Sep 09 '21 at 16:09

0 Answers0