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

Regression in pwd of cargo doc #47434

Closed
dtolnay opened this issue Jan 14, 2018 · 9 comments
Closed

Regression in pwd of cargo doc #47434

dtolnay opened this issue Jan 14, 2018 · 9 comments
Labels
P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue.
Milestone

Comments

@dtolnay
Copy link
Member

dtolnay commented Jan 14, 2018

For one of my projects I build and publish docs of the master branch from CI. I use the command RUSTDOC=./rustdoc cargo doc with a script that looks like:

#!/bin/sh

exec rustdoc "$@" --html-after-content script.js

This works as of stable rustc 1.23.0. But with rustc 1.24.0-beta.3 it no longer works because the RUSTDOC is resolved relative to /path/to/registry/src/jackfan.us.kg-$hash/$crate-$version instead of relative to the directory from which I ran cargo doc. This is different from how RUSTC=./foo cargo build is resolved so I believe it is a bug.

@dtolnay dtolnay added the regression-from-stable-to-beta Performance or correctness regression from stable to beta. label Jan 14, 2018
@dtolnay
Copy link
Member Author

dtolnay commented Jan 14, 2018

Mentioning some rustdoc contributors: @QuietMisdreavus @GuillaumeGomez

@QuietMisdreavus
Copy link
Member

😕 If it's a problem of resolving the RUSTDOC environment variable, it seems more like Cargo being weird? @rust-lang/cargo What do y'all think?

@Mark-Simulacrum
Copy link
Member

This looks like it's probably caused by rust-lang/cargo@8647a87, and as such probably intentional (cc @alexcrichton).

However, the behavior where a cargo doc invoked in the "root" package doesn't use that packages workspace root does seem rather odd, so perhaps we can make some changes there, or resolve RUSTDOC relative to the current working directory first, by calling canonicalize. It would be logical to do the same for RUSTC, then.

@Mark-Simulacrum Mark-Simulacrum added P-high High priority T-cargo Relevant to the cargo team, which will review and decide on the PR/issue. labels Jan 15, 2018
@dtolnay
Copy link
Member Author

dtolnay commented Jan 15, 2018

resolve RUSTDOC relative to the current working directory first

Haven't read through that Cargo commit, but this is what I would consider the correct behavior. From what I can tell, this is how it works for RUSTC.

Note that there are two relevant directory issues and I maybe should have mentioned the second one above:

  • Directory where RUSTDOC is resolved
  • Directory that the script given by RUSTDOC sees as its current directory

My shell script refers to script.js which exists in the directory from which cargo doc was invoked, and that used to work as of rustc 1.23.0. As of 1.24.0-beta.3 the script no longer sees that directory as its current directory.

@alexcrichton
Copy link
Member

Ok so there's two things going on here I think. As @Mark-Simulacrum pointed out this is caused by rust-lang/cargo#4788, so strictly speaking it's a bug in Cargo, not rustc. In any case:

  • It's a bug in Cargo that RUSTDOC=./foo doesn't work. That should be resolved relative to the invoking cwd and should be used as an absolute path from then on out.
  • It's "expected breakage" that the cwd is changing during compiles which would break the original script here @dtolnay is it possible to use an absolute path to script.js instead?

@Mark-Simulacrum Mark-Simulacrum added this to the 1.24 milestone Jan 15, 2018
@wycats
Copy link
Contributor

wycats commented Jan 15, 2018

@alexcrichton can we fix the Cargo bug?

@alexcrichton
Copy link
Member

@wycats the bug about RUSTDOC=./foo certainly, the "bug" about changing cwd is much less clear.

@Mark-Simulacrum
Copy link
Member

@rust-lang/cargo We need to discuss and resolve the relative rustdoc path issue RUSTDOC=./foo soon. The other discussion (cwd changing) is I believe expected, though may also be worth discussing. Nominating and setting P-high.

@Mark-Simulacrum Mark-Simulacrum added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. and removed regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Feb 19, 2018
@alexcrichton
Copy link
Member

Since this ended up hitting stable I'm going to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants