`go tool cover -html` no longer works on Ubuntu

go tool cover -html=xxx no longer works on Ubuntu 22.04, because it uses a file in /tmp but Firefox is sandboxed and can’t access the system /tmp directory (or the root directory.)

In the last few months, Firefox changed from an apt package to a snap package. Due to the way snap works, Firefox now runs in a sandbox that can’t access the system’s root directory, and /tmp as Firefox sees it is not the same as the system’s /tmp/ directory.

I opened an issue for this: cmd/cover: cover uses /tmp but ubuntu 22.04 Firefox now won't access /tmp · Issue #68343 · golang/go · GitHub . They apparently don’t think it’s a go problem that a go tool doesn’t work as described on Ubuntu.

PLEASE upvote if you think it should be fixed.

Meanwhile, here are workarounds:

  1. Use the the TMPDIR env var to override: TMPDIR=/x/y/z go tool cover -html=x.out
  2. Uninstall Firefox and reinstall using a PPA (Personal Package Archive), but note that you have to also configure the priority or it will just reinstall it using snap. See software installation - How to install Firefox as a traditional deb package (without snap) in Ubuntu 22.04 or later versions? - Ask Ubuntu
  3. Use the out= option to a file in the user’s directory and open that in Firefox (but that takes manual steps each time you run go tool cover, or else wrap it in a script and use xdg-open to open the URL.)
1 Like

See also Bug #1972762 “Firefox and Chromium snaps preventing apps and dev…” : Bugs : snapd (launchpad.net), where this issue is raised as a snapd issue.