Skip to content

Preview in browser fails in WSL with: exec: "xdg-open": executable file not found in $PATH #826

@valorin

Description

@valorin

Describe the bug

The Preview in Browser option for a new pull request (via gh pr create) fails with the following error when used in WSL (I'm using the Pengwin distro on WSL2):

exec: "xdg-open": executable file not found in $PATH

As a result, you lose the PR body you've typed into the editor and have to start the PR creation process again.

$ gh --version
gh version 0.7.0 (2020-04-22)
https://github.com/cli/cli/releases/tag/v0.7.0

$ wslsys
Locale: en_AU
Release Install Date: Sat Apr 18 18:02:48 AEST 2020
Branch: rs_prerelease
Build: 19608
Full Build: 19608.1000.amd64fre.rs_prerelease.200410-1438
Display Scaling: 1
Windows Theme: light
Windows Uptime: 0d 13h 55m
WSL Uptime: 0d 5h 16m
WSL Release: Pengwin
WSL Kernel: Linux 4.19.104-microsoft-standard
Packages Count: 659

Steps to reproduce the behavior

  1. Using WSL on Windows 10
  2. Follow the prompts in gh pr create
  3. Select the Preview in Browser option

Expected vs actual behavior

This error is thrown and the command exits, losing all information:

exec: "xdg-open": executable file not found in $PATH

Ideally it should open the browser on the host to preview the PR, as if it was run on the host directly. wslview is included with most WSL distros and can be used to open the browser in Windows 10. More information: https://github.com/wslutilities/wslu

The alternative would be to provide the user the option to submit the PR directly or display a URL to manually paste into the browser for the preview.

Logs

valorin@Pengwin:~/dev/project/www (FB834)$ gh pr create

Creating pull request for FB834 into master in project/project-www

? Title FB834: Tweak width of invoice to/from/status for comfort
? Body <Received>
? What's next? Preview in browser
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 4 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1.43 KiB | 1.43 MiB/s, done.
Total 7 (delta 6), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (6/6), completed with 6 local objects.
remote:
remote: Create a pull request for 'FB834' on GitHub by visiting:
remote:      https://github.com/project/project-www/pull/new/FB834
remote:
To github.com:project/project-www.git
 * [new branch]        HEAD -> FB834
Branch 'FB834' set up to track remote branch 'FB834' from 'origin'.
Opening github.com/project/project-www/compare/master...FB834 in your browser.
exec: "xdg-open": executable file not found in $PATH

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions