'How to use WSL as default terminal in WebStorm or any other JetBrains' products?
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?
Solution 1:[1]
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
Solution 2:[2]
Set:
Settings > Tools > Terminal > Shell path
Equal to:
"C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\ubuntu.exe" run
The result is:
Solution 3:[3]
Settings -> Tools -> Terminal
change cmd.exe
to C:\Windows\System32\bash.exe
and restart Webstorm.
Solution 4:[4]
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
Solution 5:[5]
You can just set your terminal to wsl
no path required.
Add --distribution
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.
Solution 6:[6]
Just adding an answer if you have multiple distros in your WSL and want to always use a particular one:
- Find out what WSL distros you have with
wslconfig /list
and identify the one you want to use (in my case it's "CentOS7")
- In your JetBrains product's Settings->Tools->Terminal, set the Shell path to
wsl.exe --distribution <whatever distro you choose>
. Example in CLion:
Click APPLY then OK.
Solution 7:[7]
On Windows builds 16215 and higher:
- Install WSL and the Linux distro of your choice (I opted for Ubuntu 18.04)
Windows support docs - 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
Solution 8:[8]
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
Solution 9:[9]
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.
Solution 10:[10]
set shell path
edit Windows Terminal settings
ALT + F12
Solution 11:[11]
In my case, the 'Workspace trust' setting was also a factor: After following the above answers, I was still getting errors trying to start bash when I worked on WSL projects. Coincidentally, I was getting these 'Do you trust this workspace' prompts on IDE startup (WebStorm). Once I went to Settings|Build...| Trusted Locations and set the first entry to \\$wsl\Ubuntu-20.04\home\my-login-name my shell finally worked -- whodathunkit? :) HTH others - jps
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow