Skip to content

[Your Knowledge Wanted!!] How can Tasks in VS Code automate Claude Code activation in WSL terminal? #2190

Closed
@mickitty0511

Description

@mickitty0511

Problem Description

I'm trying to run Claude Code through VS Code's tasks.json configuration in a WSL environment, but getting a "command not found" error.

Image

Environment

  • OS: Windows 11 with WSL2
  • WSL Distribution: Ubuntu-22.04
  • VS Code: Using tasks.json to run Claude in WSL terminal(* WSL terminal is the default terminal)

Current Configuration

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Run Claude in WSL Terminal",
            "type": "shell",
            "command": "claude",
            "options": {
                "shell": {
                    "executable": "wsl.exe",
                    "args": [
                        "-e",
                        "bash",
                        "-c"
                    ]
                }
            },
            "presentation": {
                "reveal": "always",
                "panel": "new"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "problemMatcher": [],
            "runOptions": {
                "runOn": "folderOpen"
            }
        }
    ]
}

Error Output

bash: line 1: claude: command not found
The terminal process "wsl.exe -e bash -c claude" terminated with exit code: 127.

Attempted Solutions

I've checked the following:

  • Node.js and npm are properly installed in WSL
  • Tried running which claude, then get a proper result "/home/[username]/.nvm/versions/node/v22.16.0/bin/claude"

I'm new to using tasks in VS Code.
Any guidance on the proper setup would be greatly appreciated!

Metadata

Metadata

Assignees

Labels

area:ideplatform:windowsIssue specifically occurs on WindowsquestionIssue is asking a question about how Claude Code works, or similar

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions