siarheiburliayeu / IDEA-Native-Terminal-Plugin

Native Terminal Plugin for JetBrains IDEs
https://plugins.jetbrains.com/plugin/9966-native-terminal
MIT License
63 stars 17 forks source link

Support bash on Windows 10 (WSL) #14

Closed petervandenbroek closed 4 years ago

petervandenbroek commented 6 years ago

Configuring bash.exe in Windows 10 (with the embedded Ubuntu installed) works fine and it opens the terminal as expected.

However, the folder it opens isn't the project directory, but the IDE bin folder. For example, in GoLand this is: "/mnt/c/Program Files/JetBrains/GoLand 2018.2.4/bin

siarheiburliayeu commented 6 years ago

Hi Peter, I will check. Thanks!

siarheiburliayeu commented 6 years ago

Could you please send the IDE log or your "Favorite terminal" line?

petervandenbroek commented 6 years ago

Favorite Terminal: "bash.exe" The Ubuntu terminal lives in system32, so can be called the same way as cmd and powershell.

Relevant IDE log lines:

2018-11-16 16:14:17,626 [24995736]   INFO - m.sburlyaev.cmd.plugin.OpenCmd - Environment{os=WINDOWS, osVersion='10.0', gui='windows'}
2018-11-16 16:14:17,627 [24995737]   INFO - yaev.cmd.plugin.CommandBuilder - Favorite terminal is [bash.exe] and using [GENERIC]
2018-11-16 16:14:17,627 [24995737]   INFO - m.sburlyaev.cmd.plugin.OpenCmd - [cmd, /c, start, bash.exe]
siarheiburliayeu commented 6 years ago

Hi @petervandenbroek , I have added support for bash (with WSL) and it will be available in a few days. Thanks for the request!

petervandenbroek commented 6 years ago

Awesome, I can confirm it works as expected.

Thanks for the quick fix!

G-Rath commented 5 years ago

@sburlyaev was this ever released? I'm using v0.4.1 from the jetbrains plugins store, and am having this issue.

siarheiburliayeu commented 5 years ago

Hi @G-Rath,

Could you share more details? Your command line, project directory, plugin log messages, etc.

G-Rath commented 5 years ago

@sburlyaev Sure can! I had intended to added that info, but didn't get the time.

I'm running Windows 10, using WSLv1.

I've tried with a number of commands:

wsl
wsl ${project_directory}
wsl 'bash -c "cd $(wslpath "${project.dir}"); $SHELL"'

My log outputs are:

2019-10-06 19:53:13,149 [45748725]   INFO - actions.OpenTerminalBaseAction - [cmd, /c, start, wsl] 
2019-10-06 19:55:51,428 [45907004]   INFO - actions.OpenTerminalBaseAction - [wsl, C:/Users/G-Rath/workspace/personal-projects/bitbucket-watcher-lambda]
2019-10-06 19:56:56,195 [45971771]   INFO - actions.OpenTerminalBaseAction - [wsl, 'bash, -c, "cd, $(wslpath, "C:/Users/G-Rath/workspace/personal-projects/bitbucket-watcher-lambda");, $SHELL"']

The issue is twofold from what I can tell: firstly, paths are not being translated to WSL paths, meaning that WSL exists w/ "No such directory", and then spaces are being replaced with ", ", making the commands invalid.

siarheiburliayeu commented 5 years ago

I can recommend to try bash or bash.exe, or full path to that. As I remember, it does not handle wsl as a shortcut.

G-Rath commented 5 years ago

I can recommend to try bash or bash.exe, or full path to that.

Just FYI MS recommend using wsl.exe:

The best way to interact with the Windows Subsystem for Linux is to use the wsl.exe command.

But bash.exe isn't deprecated, so it should serve in the meantime :)

siarheiburliayeu commented 5 years ago

Sounds reasonable. I will add wsl to known WSL keywords. Thank you!