Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustup doc appears to do nothing #1125

Closed
Diggsey opened this issue May 17, 2017 · 21 comments
Closed

rustup doc appears to do nothing #1125

Diggsey opened this issue May 17, 2017 · 21 comments
Labels
fixed-next-release This issue will be fixed in the next release of rustup.

Comments

@Diggsey
Copy link
Contributor

Diggsey commented May 17, 2017

I do see behavior on a headless linux machine where rustup doc appears to do nothing.

#1046 (comment)

@nodakai
Copy link
Contributor

nodakai commented Jun 25, 2017

$ docker run -it --name rustup-doc --security-opt seccomp:unconfined debian:jessie
# apt-get update
# apt-get -y install curl less strace
# curl https://sh.rustup.rs -sSf | sh
# PATH=$PATH:$HOME/.cargo/bin
# strace -f -s100 rustup doc |& less

In this case rustup was satisfied with just successfully launching sensible-browser when it actually complained as below and returned 1:

Couldn't find a suitable web browser!
Set the BROWSER environment variable to your desired browser.

@ghost
Copy link

ghost commented Jul 16, 2017

$ time rustup doc

real	0m0.308s
user	0m0.290s
sys	0m0.017s

Exit code is 0.

According to strace, it executed
/usr/bin/xdg-open /home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/index.html
The above(xdg-open command) shows elinks (a browser running in console) when I run it myself from xfce4-terminal and it seems to work ok. But with rustup it shows nothing.

Maybe rustup doc could always say the command it executes, so that if it fails, user can copy/paste and manually execute it?

EDIT: using this patch for my own needs.

@Natim
Copy link

Natim commented Nov 8, 2017

In my case it tried to open gvfs-open ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/share/doc/rust/html/index.html however the html folder doesn't exists here.

@Natim
Copy link

Natim commented Nov 8, 2017

~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/share/doc$ tree
.
├── cargo
│   ├── LICENSE-APACHE
│   ├── LICENSE-MIT
│   ├── LICENSE-THIRD-PARTY
│   └── README.md
└── rust
    ├── COPYRIGHT
    ├── LICENSE-APACHE
    ├── LICENSE-MIT
    └── README.md

I used rustup component add rust-docs to install them and it fixed it!

@nbro
Copy link

nbro commented Jan 18, 2018

I was also having this problem on Mac OS X, version 10.13.2. I executed

rustup component add rust-docs

as suggested by @Natim, and then I executed again

rustup doc

and a browser tab automatically opened, in my case, on Chrome, with the offline documentation.

@pickfire
Copy link
Contributor

pickfire commented Aug 8, 2018

@Diggsey Maybe you are looking for rustup man?

@britishben
Copy link

britishben commented Jan 10, 2019

In my case, it was because I don't have xdg-open installed, and /bin/open is symlinked to /bin/openvt in Ubuntu (referenced here). Maybe require xdg-open as a dependency?

Passing back an error message would be much more helpful than the current behaviour of failing silently.

@ghost
Copy link

ghost commented Jan 10, 2019

tl;dr: @britishben set BROWSER env. var. to the browser executable you want rustup doc to open the docs with. (doesn't have to be full path, anything in PATH seems to work too)


For me, xdg-open runs elinks(a browser that runs in the text terminal eg. in xfce4-terminal) but when rustup doc tries to execute it, it does so with stdin/stdout/stderr redirected to /dev/null but because stdout is redirected to /dev/null, elinks(in my case) just exits. Perceived result: rustup doc does nothing.

So this does nothing and returns exit code 0:

$ xdg-open "/home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/index.html" </dev/null 2>&1 >/dev/null ; echo "exit code:$?"
exit code:0

But this works and runs elinks just fine(and then I exit with q key):

$ xdg-open "/home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/index.html" </dev/null 2>&1 ; echo "exit code:$?"
exit code:0

Workaround: set the BROWSER env. var to the browser executable you want rustup doc to run to open the docs with:

;// before:
$ rustup doc
!! executing: xdg-open "/home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/index.html"

;// after
$ export BROWSER=chro2
$ rustup doc
!! executing: chro2 "/home/xftroxgpx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/index.html"

If the BROWSER env. var. points to an invalid/notfound command then it falls back to the list in let commands:

https://github.com/rust-lang/rustup.rs/blob/1dd60c40f7eb8a302ab54cded0e5a2b0d530adeb/src/rustup-utils/src/raw.rs#L371-L385


I'm personally still using a patch to mitigate this instead. (even though ~/.cargo/bin/rustup gets overwritten upon every successful rustup update of the nightly toolchain, or at least it used to(I haven't tried recently); so I'd have to recompile&reinstall my modified rustup again :D)

@istankovic
Copy link

@xftroxgpx I had the exact same problem and it was quite interesting to see what went wrong. The question is, why does xdg-open try to invoke elinks, even though xdg-settings get default-web-browser returns firefox.desktop?

xdg-open invokes exo-open, as it should, which then proceeds to execute gio-launch-desktop. Now, gio-launch-desktop will read /usr/share/applications/mimeinfo.cache and presumably return the first registered application for the MIME type. In particular, my entry looks like this:

text/html=elinks.desktop;firefox.desktop;

So it seems that as soon as you install another browser, there is a chance that the entry is updated in an unintended way. The cache file is updated by update-desktop-database when a package is installed (I'm using Archlinux). My first thought was that update-desktop-database is adding the entries based on sorted names so that's why elinks.desktop comes before firefox.desktop. However, that seems not to be the case, as evidenced by the updated entry after I installed chromium:

text/html=elinks.desktop;firefox.desktop;chromium.desktop;

I'd love to know what really happened here.
Of course, removing chromium will also result in removing the corresponding .desktop entry from the cache file, which hints at one way to work around this rustup issue.

But since we all love elinks and have it installed for a reason, we can just put this:

[Default Applications]
text/html=firefox.desktop;elinks.desktop

into /etc/xdg/mimeapps.list. For user-override, use ~/.config/mimeapps.list instead.

@kinnison
Copy link
Contributor

kinnison commented Jul 5, 2019

The mime handlers ought to include information on how to deal with terminal vs. not terminal. I wonder why they don't.

@japrogramer
Copy link

japrogramer commented Oct 19, 2019

my rustup doc --std does nothing

errors.txt

and my miapps
[Added Associations]
text/html=firefox.desktop;elinks.desktop;
application/pdf=firefox.desktop;
x-scheme-handler/http=firefox.desktop;
x-scheme-handler/https=firefox.desktop;
x-scheme-handler/ftp=firefox.desktop;
x-scheme-handler/chrome=firefox.desktop;
text/html=firefox.desktop;
application/x-extension-htm=firefox.desktop;
application/x-extension-html=firefox.desktop;
application/x-extension-shtml=firefox.desktop;
application/xhtml+xml=firefox.desktop;
application/x-extension-xhtml=firefox.desktop;
application/x-extension-xht=firefox.desktop;

@kinnison
Copy link
Contributor

Do you have the rust-docs component installed? (Silly question, but it's possible you might not)

Otherwise this might be another opener bug in which case @Seeker14491 might have some input/questions.

@japrogramer
Copy link

yes, i have it installed.

@Seeker14491
Copy link
Contributor

I believe I've figured out what can cause the browser not to open: xdg-open is being ran with a null stdout. Using the lynx browser, links don't open for me. Changing stdout to the default of inherit causes the browser to open properly.

@japrogramer could you share what distro, desktop environment, and web browser combination is not working for you so I can try to reproduce the issue?

@japrogramer
Copy link

@Seeker14491 I am using arch Linux, sway wm and Firefox.

@Seeker14491
Copy link
Contributor

I've opened Seeker14491/opener#4 to track this bug.

@jdl
Copy link

jdl commented Nov 17, 2019

But since we all love elinks and have it installed for a reason, we can just put this:

[Default Applications]
text/html=firefox.desktop;elinks.desktop

into /etc/xdg/mimeapps.list. For user-override, use ~/.config/mimeapps.list instead.

Thank you. I was going crazy trying to figure out why on only one of my machines when I ran rustup doc it would open Postman.

Sure enough:

$ more ~/.config/mimeapps.list 

[Default Applications]
text/html=Postman.desktop
x-scheme-handler/postman=Postman.desktop

@gdnathan
Copy link

up,
/usr/bin/xdg-open /home/erudyx/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/index.html works just fine, but rustup doc or rustup doc --book does absolutely nothing

@Seeker14491
Copy link
Contributor

@Erudyx could you respond to Seeker14491/opener#4 (comment)? Also, I'd like to know what's your distro and browser so I can try to reproduce this.

@garasubo
Copy link

According to this comment, this issue has been resolved since opener version is now 0.5?

@kinnison kinnison removed the bug label Nov 8, 2021
@kinnison kinnison added fixed-next-release This issue will be fixed in the next release of rustup. and removed help wanted E-easy labels Nov 8, 2021
@kinnison
Copy link
Contributor

1.25 is now out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed-next-release This issue will be fixed in the next release of rustup.
Projects
None yet
Development

No branches or pull requests