-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Chapter 2 - "Generating a Random Number" Instructions in NOTE don't work (rand dependency not documented) #2972
Comments
Hm, that's really strange. So each listing has its complete project code in the Could you please clone this repo, then If you run
I don't think rust-lang/cargo#3805 is relevant here, and I'm not sure what you mean by "internal dependencies". This comment mentions that I also am not sure how you got a workspace, because that's not something Chapter 2 uses either. |
This did turn out to be more interesting than I expected as it seemed so straight forward before, but no longer. I cloned the repo, ran the experiment and rand did show up in the sidebar. However, I then went back to my original ...\projects\guessing_game and reran cargo doc --open and, now, it also shows rand in the sidebar. So, one would think all was well if it wasn't for my experience of having previously followed the steps in the book (paper copy, third printing) and have it not work (repeatedly). In the interest of science (or whatever) I may remove rust from this computer tomorrow and repeat the install and the experiment and see if I can duplicate the previous failure. On the other hand, if you don't see any benefit in me attempting to duplicate the previous undesirable behavior (since is appears fixed in the current configuration) let me know and I will save myself the time. |
I'm going to assume at this point there was/is something screwed up in my installation. A clue to this affect is that running "rustup update" does not go well (failed to install component: 'rustfmt-preview-x86_64-pc-windows-msvc'... "error: could not remove 'component' directory: 'C:\Users\sstearns.rustup\toolchains\nightly-x86_64-pc-windows-msvc\share/doc/rust/html'" and, since at this stage I'm just trying to learn the basics and things mostly work for this book and the embedded book I'm just going to leave well enough alone. At some future date (and when I know more) I'll figure out how to redo the install from scratch and, if I remember, I'll rerun this test. Given all that, I'm closing the issue. |
work-in-progress update: I was forced to delete and reinstall rust after all and I reran the tests. This time around, with the cloned listings rand still appeared in the sidebar but with my original listing it does not. The listing directory upon which I did the comparison is listing-02-06 since it is at the same level of completion as mine. OS is Windows 10 Enterprise rustc -vV: cargo -vV: Rust install via: https://www.rust-lang.org/tools/install/ All execution is via powershell. |
Thank you so much for doing this investigation and providing all this information! The diff between your project and the listing in this repo was especially useful. I'm able to reproduce by putting |
Ok, I think I've figured out that this is a |
Thanks for the update and I'm glad I was able to help. |
main
branch to see if this has already been fixedURL to the section(s) of the book with this problem:
https://github.com/rust-lang/book/blob/main/src/ch02-00-guessing-game-tutorial.md
Description of the problem:
Following the instructions in the note, the documentation generated and opened does not include the documentation for the rand dependency. Per the discussion here: rust-lang/cargo#3805 It appears that it's not intended for the internal dependencies to be documented in that manner. I did try the approach shown in issue 3805 (cargo doc -p rand:0.3.23 --open) and that did allow me to see the rand documentation.
Suggested fix:
The note needs to be corrected to show the correct way which will successfully "build documentation provided by all of your dependencies locally and open it" as this would be very helpful.
It appears "cargo doc --all --open" works but I notice that the documentation for cargo doc deprecates this option in favor of --workspace which also appears to work.
The text was updated successfully, but these errors were encountered: