"rustup doc" giving error

HI, I am new to rust and was reading official rust "book", i installed rust via following cmd: curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh while the official book mentions we can open rust docs locally offline after we have installed rust, by the following command rustup doc but when I run this command, it gives me error: couldn't open browser: IO error: No such file or directory (os error 2) . How can I solve this?

maybe you installed the toolchain with minimal profile?

what is the output of the following command:

$ rustup show
$ rustup component list --installed

that seems all right, rust-docs-xxx is the offline documentation.

what is your desktop environment? specifically, what is the default web browser? if for some reason you don't have a default system web browser, you can set the BROWSER environment variable to the path of your browser. for example, if your browser command is /usr/bin/firefox, try:

env BROWSER=/usr/bin/firefox rustup doc

Working on WSL .....
Also, I tried installing in windows ... it is not even executing rustc --version there ... throwing error
Its showing the version n all successfully in wsl but rustup docs is not opening up
Is there any other way I can open this file?

I think you can use the Windows web browser, as long your wsl distribution has enabled the interop feature (enabled by default). for instance:

env BROWSER=/mnt/d/Applications/firefox-esr/firefox.exe rustup doc
1 Like

the index file is located at ~/.rustup/toolchains/<DEFAULT-TOOLCHAIN-TRIPLET>/share/doc/rust/html/index.html

I can't find this file .... Also I can't find any file/directory of rust after installing it on windows ..... :frowning:

Can confirm this works (given a path to the browser, more likely /mnt/c/Program Files/Mozilla Firefox/firefox.exe or mnt/c/Program Files/Google/Chrome/Application/chrome.exe). This opens the impossible-to-guess URL of:

file://///wsl.localhost/Ubuntu/home/<username>/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/share/doc/rust/html/index.html

Five slashes. This is also accessible with wsl$ instead of wsl.localhost, at least for me. If you're still on WSL1 then this is probably all different.

On Windows native, if you've installed rustup properly, you probably already have a default browser so rustup doc should work. That one is at:

file:///C:/Users/<username>/.rustup/toolchains/stable-x86_64-pc-windows-msvc/share/doc/rust/html/index.html

But it sounds like on Windows native, you're having trouble installing rustup at all.

It'll probably be helpful to know what errors you're getting.

env BROWSER=C:/Program Files/Mozilla Firefox/firefox.exe.sig rustup doc
I am trying this , is it ok?
None of the other things worked

4 things:

  • You can't use Windows paths on WSL. Absolute paths on Linux start with / instead of the drive letter like C:/.
  • The WSL filesystem is separate from your native Windows filesystem. However, WSL automatically mounts the Windows filesystem under /mnt/<lowercase drive letter>, so you can access your Windows C:\ from WSL using /mnt/c/.
  • When an environment variable has spaces, you need to put it in quotes or escape the spaces.
  • You're trying to use firefox.exe.sig, which is not the browser.

Putting all that together:

env BROWSER="/mnt/c/Program Files/Mozilla Firefox/firefox.exe" rustup doc

P.S. you don't need env but it doesn't affect anything in this case.

Also keep in mind that paths on Linux are case-sensitive.

1 Like

Finally it worked!!!! Thanks for answering my queries patiently :innocent:

I am going to ignore the installation problem in windows for now but this worked.

1 Like

Thanks to u as well for trying to help me out here :slight_smile: . I just had to replace /d with /c here and it worked .

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.