58
votes

I am currently using Windows 10 with WSL Ubuntu 18.04 installed. I am trying to use WSL as the default terminal in WebStorm however, I am able to use the bash from WSL but the default directory would not be set to the default project location.

Does anyone know how to set this up correctly?

9

9 Answers

135
votes

After a bit of search on google found a solution to my question.

First figure out the default wsl with the command:

C:\Windows\System32\wslconfig /list

Windows Subsystem for Linux Distributions:
Ubuntu-18.04 
Legacy (Default)

then I set the default to Ubuntu-18.04 by

C:\Windows\System32\wslconfig /setdefault Ubuntu-18.04

Finally set the terminal path in Webstrom settings>tools>terminal to

C:\Windows\System32\wsl.exe

Now open the terminal it is correctly move the current directory to the /mnt/c/blah/blah

46
votes

Set:
Settings > Tools > Terminal > Shell path

Equal to:

"C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\ubuntu.exe" run

change setting


The result is:

resulting terminal

17
votes

Settings -> Tools -> Terminal change cmd.exe to C:\Windows\System32\bash.exe and restart Webstorm.

8
votes

For me the version was fetched and set automatically, after I opened a project located in \\wsl$\Ubuntu-20.04\home\my-user.

Webstorm set the shell path to wsl.exe --distribution Ubuntu-20.04

I use Webstorm version 2020.3 EAP currently

4
votes

You can just set your teminal to wsl no path required. Add --distrobution to use another distro other than the default.

It's also automatic if you either, open a project from the distros own file system, or launch php storm from the terminal then the correct WSL distro will be used by the ide.

1
votes

On Windows builds 16215 and higher:

  1. Install WSL and the Linux distro of your choice (I opted for Ubuntu 18.04)
    Windows support docs
  2. Switch the default terminal to bash
    Settings (or Default Settings)->Tools->Terminal->Shell path: bash

I use Webstorm and Rubymine and in my case, that was all that I had to do.

PS Please note that the Webstorm update 2018.2 finally brings in full integration of WSL for Node interpreter
Webstorm 2018.2 WSL

Also, Rubymine 2018.2 has drastically improved support for remote Ruby SDK (allows to use rvm), so now it is also super easy to use WSL/remote/containerized/dockerized Ruby env
Rubymine 2018.2 released

0
votes

None of the above answers worked for me for default setting the terminal to zsh but this did

In phpstorm I have setup the setting of terminal shell path as bash.exe

Tool > Terminal

Shell Path: bash.exe

Then in the .bashrc I simply added the command at the end

/usr/bin/zsh

Now the terminal in phpstorm opens in zsh mode

0
votes

I found excellent hint. You can not change default terminal. Use only 2 steps from post forkadam

First figure out the default wsl with the command:

C:\Windows\System32\wslconfig /list

Windows Subsystem for Linux Distributions:
Ubuntu-18.04 
Legacy (Default)

then I set the default to Ubuntu-18.04 by

C:\Windows\System32\wslconfig /setdefault Ubuntu-18.04

After it drag & drop folder which you want to use in terminal windows. In WebStorm you can use "open in terminal" from context menu, but in Rider only drag & drop for open in wsl terminal with special path.

0
votes
  • set shell path enter image description here

  • edit Windows Terminal settings edit terminal settings

  • ALT + F12