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

feat(package): add --exclude-lockfile flag #15234

Merged
merged 2 commits into from
Mar 14, 2025
Merged

Conversation

weihanglo
Copy link
Member

@weihanglo weihanglo commented Feb 25, 2025

What does this PR try to resolve?

Fixes #15059
Fixes #15159

This provides an escape hatch --exclude-lockfilefor uncommon workflows
that don't verify (--no-verify is passed) the build with their unpublished packages
In effect, this takes the heuristic removed in #14815 and replaces it with a flag

When --exclude-lockfile is enabled,
cargo package will not verify the lock file if present,
nor will it generate a new one if absent.
Cargo.lock will not be included in the resulting tarball.

Together with --no-verify,
this flag decouples packaging from checking the registry index.
While this is useful for some non-normal workflows that requires
to assemble packages having unpublished dependencies.
It is recommended to use -Zpackage-workspace to package the entire
workspace, instead of opting out lockfile.

How should we test and review this PR?

The first commit was stolen from NoisyCoil@1a104b5 (credit to @NoisyCoil!)

The second added two failing cases we observed in #15059.

Additional information

@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2025

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. A-cli-help Area: built-in command-line help A-documenting-cargo-itself Area: Cargo's documentation A-interacts-with-crates.io Area: interaction with registries Command-package Command-publish S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2025
@epage
Copy link
Contributor

epage commented Feb 25, 2025

Mind cleaning up the commit history (reorder test first, squash test update), including updating commint message for new flag name?

@weihanglo
Copy link
Member Author

Mind cleaning up the commit history (reorder test first, squash test update), including updating commint message for new flag name?

Was in a haste leaving the office. Sorry.

@NoisyCoil
Copy link
Contributor

Thanks for stealing, very much appreciated! (Especially the part where I don't have to come up with a better name for the flag ;-))

weihanglo and others added 2 commits February 26, 2025 12:45
After dd698ff,
`cargo package --no-verify` at least fails in three different cases:

* An unpublished package depending on itself as a dev-dependency (cyclic self-referential dev-dependencies).
  * Can be resolved by removing the `version` field from the affected dev-dependency.
  * `-Zpackage-workspace` doesn't help with it.
* Existing `cargo package` has `--package <pkg>` specifying certain unpublished packages.
  * Can be resolved by specifying all unpublished packages in one `cargo` call.
  * `-Zpackage-workspace` also requires all dependency versions available in the target registry when calling, so doesn't help.
* `cargo package --no-verify` has been used as a kind of “plumbing commands” to create tarballs without considering dependency orders. The use cases include:
  * Preparing tarballs for other package managers.
  * Integrating into custom develop workflows for unpublished/internal crates.
  * Constructing custom/private registries.

This commit shows the former two cases.
When `--exclude-lockfile` is enabled,
`cargo package` will not verify the lock file if present,
nor will it generate a new one if absent.
Cargo.lock will not be included in the resulting tarball.

Together with `--no-verify`,
this flag decouples packaging from checking the registry index.
While this is useful for some non-normal workflows that requires
to assemble packages having unpublished dependencies.
It is recommended to use `-Zpackage-workspace` to package the entire
workspace, instead of opting out lockfile.
@epage epage added the T-cargo Team: Cargo label Feb 26, 2025
@weihanglo
Copy link
Member Author

@rfcbot fcp merge

See the PR description for what is proposed to merge.

People may want to bikeshed on the flag name, though.

@rfcbot
Copy link
Collaborator

rfcbot commented Feb 26, 2025

Team member @weihanglo has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

Page not found · GitHub · GitHub
Skip to content
404 “This is not the web page you are looking for”
@rfcbot rfcbot added proposed-final-comment-period An FCP proposal has started, but not yet signed off. disposition-merge FCP with intent to merge final-comment-period FCP — a period for last comments before action is taken and removed proposed-final-comment-period An FCP proposal has started, but not yet signed off. labels Feb 26, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented Mar 4, 2025

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot added finished-final-comment-period FCP complete and removed final-comment-period FCP — a period for last comments before action is taken labels Mar 14, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented Mar 14, 2025

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@epage epage added this pull request to the merge queue Mar 14, 2025
Merged via the queue into rust-lang:master with commit 6cf8267 Mar 14, 2025
21 checks passed
@weihanglo weihanglo deleted the lockfile branch March 14, 2025 18:21
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 14, 2025
Update cargo

15 commits in ab1463d632528e39daf35f263e10c14cbe590ce8..6cf8267012570f63d6b86e85a2ae5627de52df9e
2025-03-08 01:45:05 +0000 to 2025-03-14 15:25:36 +0000
- feat(package): add --exclude-lockfile flag (rust-lang/cargo#15234)
- Redox OS is part of the unix family (rust-lang/cargo#15307)
- docs(ref): Mention `x.y.*` as a kind of version requirement to avoid. (rust-lang/cargo#15310)
- fix(run): Disambiguate bins from different packages that share a name (rust-lang/cargo#15298)
- cargo vendor: Add context which workspace failed to resolve (rust-lang/cargo#15297)
- docs(ref): Note that target-edition is deprecated (rust-lang/cargo#15292)
- refactor(toml): Centralize target descriptions (rust-lang/cargo#15291)
- docs(refs): Add `unsafe` to `extern` while using build scripts in Cargo Book (rust-lang/cargo#15294)
- Replace unmaintained humantime crate with jiff (rust-lang/cargo#15290)
- Add terminal integration via ANSI OSC 9;4 sequences (rust-lang/cargo#14615)
- feat: add completions for add --path (rust-lang/cargo#15288)
- Allow `term.progress.when` to default (rust-lang/cargo#15287)
- docs: spelling and grammar fixes (rust-lang/cargo#15284)
- chore(deps): update cargo-semver-checks to v0.40.0 (rust-lang/cargo#15282)
- Typo fixes (rust-lang/cargo#15280)

r? ghost
@rustbot rustbot added this to the 1.87.0 milestone Mar 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area: Command-line interface, option parsing, etc. A-cli-help Area: built-in command-line help A-documenting-cargo-itself Area: Cargo's documentation A-interacts-with-crates.io Area: interaction with registries Command-package Command-publish disposition-merge FCP with intent to merge finished-final-comment-period FCP complete S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-cargo Team: Cargo to-announce
Projects
Archived in project
5 participants