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

add information about packaging crate #2408

Merged
merged 4 commits into from
Mar 13, 2024
Merged

Conversation

jonaspleyer
Copy link
Contributor

This is a minor addition. Usually when working with the build crate -l command, it is enough to apply it directly to the crate root.
However, when using cargo features such as inheritance of workspace settings (ie. version.workspace = true) it is necessary to package the crate first with cargo package.

I am aware that the wording "package" should already make this clear. However, I stumbled across this problem personally and could not figure out the solution. Please correct me if I have overlooked any other documentation where this makes more sense.

@jonaspleyer jonaspleyer requested a review from a team as a code owner February 3, 2024 23:13
@github-actions github-actions bot added the S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed label Feb 3, 2024
Copy link
Member

@syphar syphar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the improvement! This really helps!

@syphar syphar added S-waiting-on-author Status: This PR is incomplete or needs to address review comments and removed S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed labels Feb 14, 2024
@jonaspleyer
Copy link
Contributor Author

jonaspleyer commented Feb 21, 2024

Hey everyone. Sorry for taking so long. I have created a sample repo which showcases how workspaces packages cannot be build by using the commands as explained in the README.md file.

Example

https://github.com/jonaspleyer/docs_rs_workspace_package

Structure

$ tree
.
├── Cargo.toml
├── my_lib
│   ├── Cargo.toml
│   └── src
│       └── lib.rs
└── README.md

3 directories, 4 files

The actual contents of my_lib do not matter, only the two configuration files.

$ cat Cargo.toml
[workspace]
members = [
        "my_lib",
]

[workspace.package]
version = "0.1.0"

and

$ cat my_lib/Cargo.toml
[package]
name = "my_lib"
version.workspace = true

[dependencies]

Building

The build command

cargo run -- build crate -l path/to/docs_rs_workspace_package/my_lib

fails with

Error: Building documentation failed

Caused by:
    Building documentation failed

Caused by:
    invalid Cargo.toml syntax

which makes sense due to

version.workspace = true

Fix

However when running the following sequence of commands

# Run this in the directory of docs_rs_workspace_package
cargo package -p my_lib

and then building again

# Run this from the docs.rs repo
cargo run -- build crate -l path/to/docs_rs_workspace_package/target/package/my_lib-0.1.0

then the build succeeds.

@jonaspleyer
Copy link
Contributor Author

@syphar how to we continue from here? This was a lot of information in my previous comment and I am unsure how to include it in the README.md

@GuillaumeGomez
Copy link
Member

There is a docs folder. Don't hesitate to add more entries into it.

@jonaspleyer
Copy link
Contributor Author

jonaspleyer commented Feb 29, 2024

I have followed your suggestions. Somehow I feel a bit stressed when writing these things in the /docs folder.
Would it not make sense to take many of the information in the Readme.md and either include this information on docs.rs itself or possibly as a book?

Copy link
Contributor Author

@jonaspleyer jonaspleyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have inserted a more detailed description of when this problem occurs and how to circumvent it in the docs folder. I hope that this is sufficiently detailed to give a clear explanation.

@syphar syphar self-requested a review March 13, 2024 07:36
@github-actions github-actions bot added S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed and removed S-waiting-on-author Status: This PR is incomplete or needs to address review comments labels Mar 13, 2024
@syphar syphar merged commit e00048f into rust-lang:master Mar 13, 2024
11 checks passed
@github-actions github-actions bot added S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it and removed S-waiting-on-review Status: This pull request has been implemented and needs to be reviewed labels Mar 13, 2024
@syphar syphar removed the S-waiting-on-deploy This PR is ready to be merged, but is waiting for an admin to have time to deploy it label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants