Cargo: `cargo doc --open` opens VSCode instead of a browser

Created on 26 Sep 2019  ·  3Comments  ·  Source: rust-lang/cargo

Problem

When I invoke

cargo doc --open

on Ubuntu 18.04 with Chromium and Firefox available, the command decides to open VSCode instead of either of those browsers. Even when Chromium is running, VSCode is opened.

Steps

  1. Install Ubuntu
  2. Install chromium-browser and firefox
  3. Install Rust tooling via rustup
  4. Install VSCode
  5. Create library crate locally
  6. Run cargo doc --open

Not sure what else might be required to get a 100% reproduction.

Possible Solution(s)

I presume this stems from VSCode being an Electron app (right?) and Cargo somehow detects this as a browser or something?

Notes

Output of cargo version: cargo 1.38.0 (23ef9a4ef 2019-08-20)

C-bug

Most helpful comment

For reference, this issue was fixed with

$ xdg-mime default chromium-browser.desktop text/html

All 3 comments

Cargo just calls xdg-open <path_to_index.html> via https://docs.rs/opener/0.4.0/opener/.

I see, will try and see if my system is messed up in this regard.

EDIT:

Aight it seems like I found the issue:

[2001]  23:13:08 ojrask@ojrask-ubuntu:~/.local/share/applications
$ cat mimeapps.list

[Default Applications]
text/html=code-url-handler.desktop
x-scheme-handler/http=chromium-browser.desktop
x-scheme-handler/https=chromium-browser.desktop
x-scheme-handler/about=chromium-browser.desktop
x-scheme-handler/unknown=chromium-browser.desktop
x-scheme-handler/vscode=code-url-handler.desktop

Will fix this, sorry for noise!

For reference, this issue was fixed with

$ xdg-mime default chromium-browser.desktop text/html
Was this page helpful?
0 / 5 - 0 ratings

Related issues

rodoufu picture rodoufu  ·  3Comments

ehuss picture ehuss  ·  3Comments

sdroege picture sdroege  ·  3Comments

fprijate picture fprijate  ·  3Comments

SimonSapin picture SimonSapin  ·  3Comments