Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode terminal task not using zsh profile

I'm trying to run a task on window load in VSCode where a terminal opens and nvm use && yarn dev is run by default. However, running this shell tasks seems to not load my zsh profile.

The output I get from running my task is:

The terminal process "zsh '-c', 'nvm use && yarn dev'" terminated with exit code: 127.

Terminal will be reused by tasks, press any key to close it.

But if I then manually start a new terminal and run the same command (ie: by pressing plus, opening a new integrated terminal), it will work as intended.

Suspecting that VSCode isn't loading my profile for some reason, I tried adding the following to my task, it resulted in the error /bin/zsh: can't open input file: nvm use && yarn dev The terminal process "zsh '-l', 'nvm use && yarn dev'" terminated with exit code: 127..

// in dev task
"options": {
  "shell": {
    "executable": "zsh",
    "args": ["-l"]
  }
},

.vscode/tasks.json

{
    "version": "2.0.0",
    "presentation": {
      "echo": false,
      "reveal": "always",
      "focus": false,
      "panel": "dedicated",
      "showReuseMessage": true
    },
    "tasks": [
      {
        "label": "Create terminals",
        "dependsOn": [
          "Dev",
        ],
        // Mark as the default build task so cmd/ctrl+shift+b will create them
        "group": {
          "kind": "build",
          "isDefault": true
        },
        // Try start the task on folder open
        "runOptions": {
          "runOn": "folderOpen"
        }
      },
      {
        "label": "Dev",
        "type": "shell",
        "command": 
          ["nvm use && yarn dev"],
        "isBackground": true,
        "problemMatcher": [],
        "presentation": {
          "group": "dev-group"
        }
      },
    ]
  }
like image 650
thefoxrocks Avatar asked Nov 19 '25 05:11

thefoxrocks


1 Answers

This worked for me*:

"terminal.integrated.profiles.osx": {
    "zsh": {
        "path": "/bin/zsh",
        "args": ["-l", "-i"]
    }
},

*(add to your settings.json)

github.com/microsoft/vscode/issues/143061

Update- For default shell provide the below setting-

"terminal.integrated.defaultProfile.osx": "zsh"
like image 95
Vikrant Avatar answered Nov 22 '25 03:11

Vikrant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!