Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support different WSL Distributions #1309

Closed
mhofman opened this issue Nov 4, 2017 · 14 comments
Closed

Support different WSL Distributions #1309

mhofman opened this issue Nov 4, 2017 · 14 comments

Comments

@mhofman
Copy link

mhofman commented Nov 4, 2017

Versions

ConEmu build: 170807 x64
OS version: Windows 10.0.16299.x64
Used shell version: WSL

Problem description

Right now WSL support seems to be limited to invoking the default distribution when using wslbridge and the cygwin/msys2 connector.

wslbridge supports a --distro-guid option to invoke a specific Distribution listed under HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss. See rprichard/wslbridge#14

Can this be exposed on the connectors? Or more generally, is there be a way to passthrough arguments to wslbridge when invoking the connector?

@mhofman
Copy link
Author

mhofman commented Nov 4, 2017

Wondering what is the "better" way to use WSL: through wslbridge or simply invoking wsl.exe -new_console:pm:/mnt [{guid}] which seems to work out of the box? (And I guess the -new_console:p won't be needed after #1291 ?)

With wsl.exe, you get true login shell on the distribution of your choice, but broken console (colors, and possibly other things like resizing).
With the bridge you currently can't get a proper login shell, a non bash shell, nor selectable distribution.

@fpqc
Copy link

fpqc commented Nov 7, 2017

@mhofman you can pass wslbridge its own arguments after the --wsl flag.

So if it's supported in wslbridge to launch a different distro, you can pass it its own arguments. You should ask here: https://github.com/rprichard/wslbridge

@mhofman
Copy link
Author

mhofman commented Nov 7, 2017

It does support it in the 0.24 version of wslbridge

After some some trial and error, I did finally figure it out. The trick was to add a - after the --wsl flag.

For anyone searching, I managed to get a Login shell through wslbridge, using a specific distribution.

Here is the full command line I used:

%ConEmuBaseDirShort%\conemu-msys2-64.exe --wsl -cur_console:pm:/mnt - -t --distro-guid {0302fe33-e328-413d-8520-077ab52d55ad} -- /bin/bash -i -l

@mhofman mhofman closed this as completed Nov 7, 2017
@fpqc
Copy link

fpqc commented Nov 7, 2017

@mhofman eh, how does that whole thing work? Why does -t get followed by --distro-guid, then --, then the shell and its arguments

@Maximus5
Copy link
Owner

Maximus5 commented Nov 8, 2017

Everything (except -new_console) after --wsl is passed directly to wslbridge, so I believe there are spare flags in the solution.

@mhofman
Copy link
Author

mhofman commented Nov 8, 2017

Anything after the first - is the args passed to wslbridge.exe. I had to include this, without it, the arguments were ingested by the connector itself, with it complaining of unknown args.

The -t is to get wslbridge to open a pty since we're executing a command.

Anything after the -- is the command executed by wslbridge-backend.

@fpqc
Copy link

fpqc commented Nov 8, 2017

@mhofman you can put the current_console part at the very end and then you don't need all those dashes

@isanych
Copy link

isanych commented May 21, 2018

I was not able to use solution above, was getting error about inability to run -
So I ended up modifying my wslbridge binary so it get distro guid from environment (I already had custom binary supporting docker compatible disks mounts anyway):
set "DISTROGUID={3d833ab2-222f-4e10-8ceb-d56423d90556}" & set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl -cur_console:pm:/mnt

commit - isanych/wslbridge@d51470c

@Maximus5
Copy link
Owner

What was the error message?

@isanych
Copy link

isanych commented May 21, 2018

set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl -cur_console:pm:/mnt - -t --distro-guid {3d833ab2-222f-4e10-8ceb-d56423d90556} -- /bin/bash -i -l

error: could not exec '-': No such file or directory

ConEmuC: Root process was alive less than 10 sec, ExitCode=0.

ConEmu 180506 [64] on Windows Server 2019 17650

@Maximus5
Copy link
Owner

Why do you pass this - as argument? Simple --distro-guid={3d833ab2-222f-4e10-8ceb-d56423d90556} is enough addition.

set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl --distro-guid={3d833ab2-222f-4e10-8ceb-d56423d90556} -cur_console:pm:/mnt

@isanych
Copy link

isanych commented May 22, 2018

yes, it is working like this. I was using command from comment above in thread and help

conemu-cyg-64.exe --help
ConEmu cygwin/msys connector version 1.2.5
Windows drive mount root: `/cygdrive`
Usage: conemu-cyg-64 [switches] [- | shell [shell switches]]
  -?, -h, --help   this help
  -d, --dir <dir>  chdir to `dir` before starting shell
                   forces `set CHERE_INVOKING=1`
  -l, --log <dir>  write console IN and OUT to files in `dir` folder
                   use current folder if <dir> is not specified`
  -t <new-term>    forces `set TERM=new-term`
      --debug      wait for debugger for 60 seconds
      --environ    print environment on startup
      --isatty     do isatty checks and print pts names
      --keys       read conin and print bare input
      --shlvl      forces `set SHLVL=1` to avoid terminal reset on exit
      --verbose    additional information during startup
      --version    print version of this tool
      --wsl        run wslbridge to start Bash on Ubuntu on Windows 10

Could not google other samples of usage distro-guid in conemu beside this issue.
--wsl --distro-guid={3d833ab2-222f-4e10-8ceb-d56423d90556} -cur_console:pm:/mnt is good.

@larsw
Copy link

larsw commented Nov 20, 2018

Ok, where can I look up the distro guids?

@Maximus5
Copy link
Owner

Have you read docs?
https://conemu.github.io/en/BashOnWindows.html#wsl-distro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants