cargo: `cargo doc --open` doesn't work in WSL
I’m using ubuntu(WSL) in windows, and I found this problem.
At the beginning, without any configuration, I got some error message. Following the error message, I set BROSWER environmental variable, and the error was gone and browser is opened. However nothing appear, seems it open browser but forget pass the “*.html”.
I’m sure it the BROWSER is set correctly, because follow command /usr/bin/sensible-browser xxx/inndex.html works well in shell.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 14
- Comments: 20 (6 by maintainers)
Commits related to this issue
- the return of the working solution github.com/rust-lang/rustup/issues/2206 github.com/rust-lang/cargo/issues/7557 — committed to yilisharcs/.dotfiles by yilisharcs 2 years ago
A short-term solution is to run
explorer.exe .or point it to your project path, navigate to/target/doc/{package_name}, and then double-clickindex.html.This can be solved with below
and add
export BROWSER='xxx/open_browser.sh'to ~/.bashrcIf you use Brave Browser with Ubuntu 20.04:
~/.scripts/open_browser.shchmod +x ~/.scripts/open_browser.shexport BROWSER='~/.scripts/open_browser.sh'to~/.bashrcNow,
cargo doc --openshould work as expected.It works after update Cargo 1.55 without BROWSER env!
.bashrc:wslpath -wcommand(in chrome.sh), then use the soft linked browser open the html page: