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

cargo doc doesn't work on a project named rustdoc #4283

Closed
steveklabnik opened this issue Jul 13, 2017 · 11 comments
Closed

cargo doc doesn't work on a project named rustdoc #4283

steveklabnik opened this issue Jul 13, 2017 · 11 comments
Labels

Comments

@steveklabnik
Copy link
Member

steveklabnik commented Jul 13, 2017

So uh,

> git clone https://github.com/steveklabnik/rustdoc
> cd rustdoc
> cargo doc

gives

 Documenting matches v0.1.6
 Documenting bitflags v0.9.1
 Documenting percent-encoding v1.0.0
 Documenting regex-syntax v0.3.9
error: Found argument '--crate-name' which wasn't expected, or isn't valid in this context

USAGE:
    rustdoc.exe [OPTIONS] [SUBCOMMAND]

For more information try --help
error: Could not document `matches`.

Caused by:
  process didn't exit successfully: `rustdoc --crate-name matches C:\Users\steve\.cargo\registry\src\gi
thub.com-1ecc6299db9ec823\matches-0.1.6\lib.rs -o C:\Users\steve\src\rustdoc\target\doc -L dependency=C
:\Users\steve\src\rustdoc\target\debug\deps` (exit code: 1)error: Found argument '--crate-name' which w
asn't expected, or isn't valid in this context

USAGE:
    rustdoc.exe [OPTIONS] [SUBCOMMAND]

For more information try --help

error: Found argument '--crate-name' which wasn't expected, or isn't valid in this context

USAGE:
    rustdoc.exe [OPTIONS] [SUBCOMMAND]

For more information try --help
warning: build failed, waiting for other jobs to finish...
error: Could not document `bitflags`.

Caused by:
  process didn't exit successfully: `rustdoc --crate-name bitflags C:\Users\steve\.cargo\registry\src\g
ithub.com-1ecc6299db9ec823\bitflags-0.9.1\src\lib.rs -o C:\Users\steve\src\rustdoc\target\doc --cfg fea
ture="default" --cfg feature="example_generated" -L dependency=C:\Users\steve\src\rustdoc\target\debug\
deps` (exit code: 1)error: Found argument '--crate-name' which wasn't expected, or isn't valid in this
context

USAGE:
    rustdoc.exe [OPTIONS] [SUBCOMMAND]

For more information try --help

warning: build failed, waiting for other jobs to finish...
error: Could not document `percent-encoding`.

Caused by:
  process didn't exit successfully: `rustdoc --crate-name percent_encoding C:\Users\steve\.cargo\regist
ry\src\github.com-1ecc6299db9ec823\percent-encoding-1.0.0\lib.rs -o C:\Users\steve\src\rustdoc\target\d
oc -L dependency=C:\Users\steve\src\rustdoc\target\debug\deps` (exit code: 1)
warning: build failed, waiting for other jobs to finish...
error: Could not document `regex-syntax`.

Caused by:
  process didn't exit successfully: `rustdoc --crate-name regex_syntax C:\Users\steve\.cargo\registry\s
rc\github.com-1ecc6299db9ec823\regex-syntax-0.3.9\src\lib.rs -o C:\Users\steve\src\rustdoc\target\doc -
L dependency=C:\Users\steve\src\rustdoc\target\debug\deps` (exit code: 1)

This is because steveklabnik/rustdoc does not yet support the --crate-name flag. Why is it trying to use the rustdoc inside of target rather than the real one?

Maybe this is a WONTFIX, but I figured I'd file it just in case.

@mbrubeck
Copy link
Contributor

This may be Windows-specific. On Linux I get "error: cannot document a package where a library and a binary have the same name", and if I work around that by setting a different name in a [lib] section of Cargo.toml, then cargo doc succeeds.

@steveklabnik
Copy link
Member Author

steveklabnik commented Jul 14, 2017

Ah sorry, I forgot that I didn't actually commit the

[[bin]]
name = "rustdoc"
doc = false

line. Doing that now...

So yeah, maybe a Windows thing.

Oh, wait:

setting a different name in a [lib] section

This is not what I did; can you try the [[bin]] version instead?

@mbrubeck
Copy link
Contributor

cargo doc runs successfully on Linux in the current steveklabnik/rustdoc master branch (with [[bin]] doc = false).

@alexcrichton
Copy link
Member

This is probably because cargo doc by default will munge PATH on Windows to ensure that DLLs can be found. In the case that your project is producing an executable called rustdoc this means that when running the process rustdoc your local project is executed instead of the actual rustdoc executable.

@steveklabnik
Copy link
Member Author

Ah ha! So yeah, that seems like a WONTFIX to me. Thanks!

@mbrubeck
Copy link
Contributor

Would it be possible to fix this by appending the target directory to PATH instead of prepending it, or would that break other things? The relevant code is here:

search_path.extend(util::dylib_path().into_iter());

@alexcrichton
Copy link
Member

Ah unfortunately not b/c the intention there is to prepend (e.g. libs in the target dir take priority). @steveklabnik I wouldn't necessarily say this is a WONTFIX, I think it's reasonable to detect the project's name is literally rustdoc and use absolute paths to rustdoc instead of relative as a result.

@steveklabnik steveklabnik reopened this Jul 14, 2017
@steveklabnik
Copy link
Member Author

Cool, I wasn't sure if this was too niche to support or not!

Should we do that unconditionally, regardless of platform, or also detect the rustdoc + Windows exactly?

@alexcrichton
Copy link
Member

Ideally I think we'd do it unconditionally, but it wouldn't be a "pretty" patch in the sense that where cargo doc -v today prints Running rustdoc ... it'll now print Running /pth/to/rustodc ... which isn't the best user experience. I'd be ok with a targeted fix for just rustdoc + Windows exactly, but I can see where it'd certainly be quite odd compared to the rest of the code...

@PaulDance
Copy link
Contributor

I personally can't reproduce this when checking out 94f5780 from https://github.com/steveklabnik/rustdoc, although I'm under a Linux distro. Had to use nightly because of a dependency it seems. @steveklabnik does it still occur for you?

@steveklabnik
Copy link
Member Author

I am not developing that project anymore, so I don't know. You shouldn't need my specific checkout though.

That being said, a new project named rustdoc does seem to work, so apparently this has been fixed! Thanks for checking in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants