cargo doc and linux default browser
October 02, 2019
So I recently learned about cargo doc --open while attending the Colorado Gold Rust conference. However, on my linux mint machine it opened the docs in chrome instead of my default web browser which is firefox. Since I spent most of my morning rust coding time tracking down why that was and how to fix it, I figured I write a blog post about it. So here goes:
- By looking at the cargo source, I was able to see that a separate crate named
openerwas used for this - By reading the
openerdocs and source, I determined it runsxdg-openbut not the one from my OS package manager, a separate copy it has bundled with the crate. (xdg-open is a shell script). - I tried running
xdg-open target/doc/my-crate/index.htmldirectly on the command line and noticed it opened the wrong browser, too. - By editing my system-level xdg-open to add
set -xdebugging, I was able to determine that my xdg-open was eventually callinggio openwhich I had never heard of. - So I read a bunch of gio docs that said the configuration comes from a file called
mimeapps.list- And of course, there's many locations where this file can live and both an old deprecated set of locations that is widely documented online and a new set of actual working locations with scant documentation
- I tried a bunch of wrong locations where
mimeapps.listmight need to be with no success - I eventually found this Arch Wiki page that described the format and accurate location of mimeapps.list:
~/.config/mimeapps.list - In there I found a bunch of stuff and every time I saw
google-chrome.desktopI just preceeded it withfirefox.desktop;and that seemed to work