netrw#BrowseX fails when invoked from gvim on Ubuntu

122 views
Skip to first unread message

Garvin Haslett

unread,
Mar 4, 2020, 9:35:30 PM3/4/20
to vim_use
I am using Vim 8.2 on Ubuntu 18.04.3

If I launch gvim and enter 

:call netrw#BrowseX('http://github.com', 0) 

the window flickers instantaneously and nothing further happens.

Performing the same action in terminal vim opens the URL in the browser as expected.

It seems likely that this is an issue with how Gnome hands this off to Linux. But where do I begin to prove this?

Garvin Haslett

unread,
Mar 10, 2020, 5:11:59 AM3/10/20
to vim_use
No answer, so I suppose this question isn't regarded as relevant.
Can anyone point me somewhere I can ask gvim specific questions?

Christian Brabandt

unread,
Mar 10, 2020, 5:37:06 AM3/10/20
to vim_use

On Di, 10 Mär 2020, Garvin Haslett wrote:

> No answer, so I suppose this question isn't regarded as relevant.
> Can anyone point me somewhere I can ask gvim specific questions?

The list is correct, however perhaps nobody knows an answer to your
problem?

If you don't mind debugging netrw, have a look at `:h netrw-debug`
or try to manually step through the commands using
`:debug :call netrw#BrowseX(...)`
(see for a brief help `:h :debug`)

My guess is, netrw calls xdg-open, which calls a script depending on
your desktop-environment something like `exo-open` or `gnome-open` and
some of those commands returns an error (or is not installed).

Best,
Christian

Charles Campbell

unread,
Mar 11, 2020, 3:00:30 AM3/11/20
to vim...@googlegroups.com
Well, here's two issues:

1) netrw requires a trailing "/", so you need 'http://github.com/' . 
Didn't you get an error message at the bottom of the display?
2) unless you're hosting github.com on your personal pc, you probably
want "remote"

When I tried this with gx with the cursor atop the (corrected)
http://github.com/ string, I got the html source as expected; that's
with Scientific Linux.
So, as Christian Brabandt said, use netrw's debug mode and find out what
its doing on your system.  If doing like I did (with gx) works, then run
debugging with that, too, and compare.

Regards,
Chip Campbell

Garvin Haslett

unread,
Mar 12, 2020, 6:16:05 PM3/12/20
to vim_use
On Tuesday, 10 March 2020 09:37:06 UTC, Christian Brabandt wrote:


If you don't mind debugging netrw, have a look at `:h netrw-debug`
or try to manually step through the commands using
`:debug :call netrw#BrowseX(...)`
(see for a brief help `:h :debug`)

My guess is, netrw calls xdg-open, which calls a script depending on
your desktop-environment something like `exo-open` or `gnome-open` and
some of those commands returns an error (or is not installed).


I don't mind at all. The first step of the process (invoking vim/gvim without other plugins) confirmed that we see the same behaviour outlined in my original message, i.e., vim invoked from the command line successfully sends the URL to chrome while gvim does not. 

Attached is the Decho output produced by the call using gvim.

The key lines seem to be:

|s:NetrwExe(a:cmd<sil !xdg-open 'http://github.com/'>/dev/null 2>&1>) {
||exe sil !xdg-open 'http://github.com/'>/dev/null 2>&1 ~10
||return s:NetrwExe : v:shell_error=0 }

which, to my (untrained) eye looks like a successful call.
Am I correct?
netrw_gvim.dbg

Garvin Haslett

unread,
Mar 12, 2020, 8:15:08 PM3/12/20
to vim_use
I worked it out finally, this is a known issue with how gvim handles shell commands:
https://superuser.com/questions/386646/xdg-open-url-doesnt-open-the-website-in-my-default-browser

In short netrw#BrowseX does invoke a call to xdg-open which command line vim deals with as expected.
It seems that gvim spawns some sort of temporary process which is then killed instantaneously; thus preventing the request from making it to the browser. 
Reply all
Reply to author
Forward
0 new messages