Running MarkdownPreview throws uncaught exception: Error: spawn xdg-open ENOENT in WSL 2 with terminal Vim

See original GitHub issue

Hi,

I’m using Vim 8.1 inside of Ubuntu 20.04 running in WSL 2 using the latest pull from master at the time of writing this comment.

Inside of WSL 1 this plugin worked great. It would open my default browser when running that command without having to do anything custom.

But now within WSL 2 it fails to run :MarkdownPreview with:

[markdown-preview.vim] uncaught exception: Error: spawn xdg-open ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

Turns out you need to install sudo apt-get install -y xdg-utils, and then things work fine. Although there is a ~5 second delay before it opens where as with WSL 1 it was instant.

Might be worth adding something to the docs or wiki for such an issue in a WSL section.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
caoshenghuicommented, Sep 7, 2020

There is my solution: sudo ln -s /mnt/c/Program\ Files\ (x86)/Microsoft/Edge/Application/msedge.exe /usr/bin/edge let let g:mkdp_browser = ‘edge’

2reactions
ndamancommented, Aug 26, 2020

I just wanted to mention, using WSL2 (Arch if that makes a difference) the above methods did not work for me.

What DID work was to install wslu and set g:mkdp_browser='wslview' in my vimrc (well, init.vim). I have not experienced the multi-second delays the others are talking about using this approach.

Read more comments on GitHub >

github_iconTop Results From Across the Web

nivo tooltipFormat should allow fully custom formatting - TypeScript
... DOMPurify Running MarkdownPreview throws uncaught exception: Error: spawn xdg-open ENOENT in WSL 2 with terminal Vim - JavaScript markdown-preview.nvim.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found