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

Launch browser from BashOnWindows / WSL #2733

Open
mstrelan opened this issue May 2, 2017 · 2 comments
Open

Launch browser from BashOnWindows / WSL #2733

mstrelan opened this issue May 2, 2017 · 2 comments

Comments

@mstrelan
Copy link

mstrelan commented May 2, 2017

I'm using drush via BashOnWindows and wondering if it's possible to launch a browser with drush uli.

Outside of drush I can launch a browser with cmd.exe /c start "https://github.com/drush-ops/drush" and wondering if I can coerce drush to run a similar command. I tried drush uli --browser="cmd.exe /c start" but to no avail.

I've also tried explorer.exe "https://github.com/drush-ops/drush" which opens the default browser but again doesn't work as a drush option for the --browser parameter.

Is this a drush limitation or something else?

UPDATE: I tried with verbose output:

No graphical display appears to be available, not starting browser.

Can this be bypassed?

@mstrelan
Copy link
Author

mstrelan commented May 2, 2017

I'm not sure the best way to detect BashOnWindows, but removing this block allows the browser to launch with --browser="explorer.exe"

if (!drush_get_context('DRUSH_SIMULATE') && !getenv('DISPLAY') && !drush_is_windows() && !drush_is_osx()) {
  drush_log(dt('No graphical display appears to be available, not starting browser.'), 'notice');
  return FALSE;
}

I can also add this further down to automatically detect explorer.exe.

if (drush_shell_exec('which explorer.exe')) {
  $browser = 'explorer.exe';
}

But it needs to appear as the first condition, because open also exists on BashOnWindows but doesn't launch the browser.

@mstrelan
Copy link
Author

mstrelan commented May 2, 2017

I think we need a bash_is_wsl() function. Apparently the best way to check for WSL is to grep "Microsoft" in /proc/sys/kernel/osrelease or /proc/version.

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

1 participant