Skip to content

Improve rustup doc UX with sandboxed default browser #4975

Description

@Aneesh-382005

Problem you are trying to solve

rustup doc currently opens the local Rust documentation using the system's default browser.

On Ubuntu, if the default browser is a sandboxed browser (such as the Snap packages of Brave or Firefox), the browser may be unable to access the documentation stored under ~/.rustup via a file:// URL. From the user's perspective, rustup doc appears to fail and the browser only displays an "Access denied" or similar error.

This appears to be caused by the browser's sandbox rather than a bug in rustup. However, the current experience is confusing because users receive no indication that the failure is caused by browser restrictions or what they can do instead.

Solution you'd like

Ideally, rustup doc could provide a more helpful experience when the local documentation cannot be opened.

Some possible approaches (not prescriptive) are:

  • Detect when opening the documentation fails and print a message explaining that sandboxed browsers (such as Snap or Flatpak packages) may not be able to access documentation stored under ~/.rustup.
  • Suggest a workaround, such as using the online documentation or serving the local documentation over HTTP.
  • If feasible, consider providing an option to serve the documentation locally instead of relying on file:// URLs.

I don't have a specific implementation in mind. The main goal is to make it easier for users to understand why rustup doc did not work and how they can access the documentation.

Notes

Environment

  • Ubuntu
  • Rust installed via rustup
  • Reproduced with the Snap versions of both Brave (default browser) and Firefox

Reproduction

rustup doc

The browser fails to open the local documentation, reporting an access denied error.

Investigation

The documentation exists and is readable. Copying it outside ~/.rustup allows it to open normally, which suggests the issue is due to browser sandbox restrictions on file:// access rather than the documentation itself.

Current workaround

Serve the documentation over a local HTTP server:

cd ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/share/doc/rust/html
python3 -m http.server 8000

Then open:

http://localhost:8000

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions