rustup: rustup doc does not work on Windows/WSL
Problem
On Windows, using WSL 2, rustup doc --std (or any other rustup doc command) opens firefox correctly (because I have BROWSER=firefox.exe), but the browser does not load a file; the browser is empty/blank.
I found the rustup docs here:
~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/index.html
I could open this manually like this:
firefox.exe file://///wsl$/Ubuntu/home/kobenauf/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/index.html
Or like this:
firefox.exe `wslpath -w ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/index.html`
Possible Solution(s)
Consider making rustup doc aware of how to open files on WSL so they open the docs as expected.
Notes
Output of rustup --version:
rustup 1.21.1 (7832b2ebe 2019-12-20)
Output of rustup show:
Default host: x86_64-unknown-linux-gnu
rustup home: /home/kobenauf/.rustup
installed toolchains
stable-x86_64-unknown-linux-gnu nightly-x86_64-unknown-linux-gnu (default)
installed targets for active toolchain
wasm32-unknown-unknown x86_64-pc-windows-gnu x86_64-unknown-linux-gnu
active toolchain
nightly-x86_64-unknown-linux-gnu (default) rustc 1.42.0-nightly (689fca01c 2020-01-17)
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 13
- Comments: 30 (14 by maintainers)
Commits related to this issue
- Update `opener` crate Fixes #2206, #2642 — committed to Seeker14491/rustup.rs by Seeker14491 3 years ago
- Update `opener` crate Fixes #2206, #2642 — committed to rbtcollins/rustup.rs by Seeker14491 3 years ago
Dear all,
I found an easy way to solve this question.
Adding the prompt below in .zshrc or .bashrc:
It works for me. Maybe you should alter the real executing path of browser. ❤️
If you’re in Windows11 with wslg, then just install firefox in your WSL Ubuntu, and run “rustup doc”.
The wslg will open the firefox brower in WSL with the right content for you. Works like a charm!
Example solution I came up with:
Write this bash to a script (e.g.
$HOME/bin/wsl_browser.sh), thenexport BROWSER="$HOME/bin/wsl_browser.sh"andsudo ln -s $HOME/bin/wsl_browser.sh /usr/local/bin/xdg-openand seems to get rid of most problems I have at CLI. Haven’t found a use-case to keep any form of a realxdg-openaround on wsl.Well currently users can’t just swap out their
xdg-open, because we’re shipping our ownxdg-open, though we could change theopenercrate to try using the systemxdg-openfirst before falling back to our ownxdg-open. Of course, it would be nice if this worked out-of-the-box, so @kinnison’s suggestion seems like a viable option. Basically, we would use thewslpathcommand in our modifiedxdg-opento convert from a WSL path to a Windows path, whenever the script tries to launch an.exe.@paulirotta check your wsl version. If it is 1, then this is the known issue with newer glibc, and you either need to downgrade glibc or upgrade wsl. However, you’ve commented on an unrelated bug sso I’m going to delete your comment, and mine both in a few minutes.