moth
moth

Reputation: 2389

visual studio code command not working on wsl2, only when trying to create new file

For some strange reason, whenever I try to create a new file from the command line visual studio code it does not work:

For example:

code hello.txt does not work. But if I want to open a directory with code . it does work. I already tried uninstalling vscode but it did not work as well.

P.S: This happens inside wsl2

Upvotes: 0

Views: 166

Answers (2)

Kevin Loughead
Kevin Loughead

Reputation: 44

Same issue here. As a workaround, you could add

new() {
    touch $1
    code $1
}

to ~/.bashrc, and open new files with new filename.

Upvotes: 1

Jamie Chang
Jamie Chang

Reputation: 31

I'm having the same issue, just started today. Oddly enough:

touch hello.txt
code hello.txt

Seems to work fine. Could potentially create a shortcut for that. Although the concern is if there's a setting that was inadvertently misconfigured.

Upvotes: 1

Related Questions