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

Import the cargo-vendor subcommand into Cargo #6869

Merged
merged 1 commit into from
Jun 3, 2019

Conversation

alexcrichton
Copy link
Member

This commit imports the external alexcrichton/cargo-vendor
repository
into Cargo itself. This means it will no longer be
necessary to install the cargo-vendor subcommand in order to vendor
dependencies. Additionally it'll always support the latest feature set
of Cargo as it'll be built into Cargo!

All tests were imported as part of this commit, but not all features
were imported. Some flags have been left out that were added later in
the lifetime of cargo vendor which seem like they're more questionable
to stabilize. I'm hoping that they can have separate PRs adding their
implementation here, and we can make a decision of their stabilization
at a later date.

The current man page for cargo vendor -h will look like:

cargo-vendor
Vendor all dependencies for a project locally

USAGE:
cargo vendor [OPTIONS] [--] [path]

OPTIONS:
-q, --quiet                    No output printed to stdout
    --manifest-path <PATH>     Path to Cargo.toml
    --no-delete                Don't delete older crates in the vendor directory
-s, --sync <TOML>...           Additional `Cargo.toml` to sync and vendor
    --respect-source-config    Respect `[source]` config in `.cargo/config`
-v, --verbose                  Use verbose output (-vv very verbose/build.rs output)
    --color <WHEN>             Coloring: auto, always, never
    --frozen                   Require Cargo.lock and cache are up to date
    --locked                   Require Cargo.lock is up to date
-Z <FLAG>...                   Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details
-h, --help                     Prints help information

ARGS:
<path>    Where to vendor crates (`vendor` by default)

This cargo subcommand will vendor all crates.io and git dependencies for a
project into the specified directory at `<path>`. After this command completes
the vendor directory specified by `<path>` will contain all remote sources from
dependencies specified. Additionally manifest beyond the default one can be
specified with the `-s` option.

The `cargo vendor` command will also print out the configuration necessary
to use the vendored sources, which when needed is then encoded into
`.cargo/config`.

Since this change is not importing 100% of the functionality of the
existing cargo vendor this change does run a risk of being a breaking
change for any folks using such functionality. Executing cargo vendor
will favor the built-in command rather than an external subcommand,
causing unimplemented features to become errors about flag usage.

@rust-highfive
Copy link

r? @nrc

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 23, 2019
@alexcrichton
Copy link
Member Author

Note that I suspect we can't land this necessarily as-is, but I wanted to get the conversation started!

@ehuss could you help me out a bit with src/doc/man? Are the adoc files edited by hand and then everything else is generated?

@ehuss
Copy link
Contributor

ehuss commented Apr 23, 2019

@ehuss could you help me out a bit with src/doc/man? Are the adoc files edited by hand and then everything else is generated?

Yes, the adoc files are written by hand. You need to install asciidoctor and run make in src/doc. I can write it and push to your branch if you want.

@alexcrichton
Copy link
Member Author

Now with documentation!

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

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

To add the man page to the website, it needs to be added to src/doc/src/SUMMARY.md. I'm not sure which category to put it in, maybe "manifest commands" or create a new category? Then add a markdown file that includes the html (see src/doc/src/commands/cargo-build.md as an example).

(I have to go, not sure what is wrong with ignore_files extracting a file, will take a look when I return.)

src/bin/cargo/commands/vendor.rs Outdated Show resolved Hide resolved
src/bin/cargo/commands/vendor.rs Outdated Show resolved Hide resolved
src/cargo/ops/vendor.rs Outdated Show resolved Hide resolved
src/cargo/ops/vendor.rs Outdated Show resolved Hide resolved
tests/testsuite/vendor.rs Outdated Show resolved Hide resolved
@ehuss
Copy link
Contributor

ehuss commented Apr 29, 2019

Looks great! Is this ready to go? If so, r=me. It wasn't clear to me if there was more you wanted to do now.

@bors
Copy link
Contributor

bors commented Apr 29, 2019

☔ The latest upstream changes (presumably #6865) made this pull request unmergeable. Please resolve the merge conflicts.

@alexcrichton
Copy link
Member Author

Do you have thoughts on the breakage relative to cargo-vendor itself? I'm personally ok landing this and just saying "use cargo-vendor vendor ... if you're using the options, but we could also possibly go ahead and implement them in Cargo behind -Z or something like that.

@ehuss
Copy link
Contributor

ehuss commented Apr 29, 2019

Just to be clear, is this the set of flags we are talking about?

-x, --explicit-version   Always include version in subdir name
--disallow-duplicates    Disallow two versions of one crate
--only-git-deps          Only vendor git dependencies, not crates.io dependencies
--relative-path          Use relative vendor path for .cargo/config
--no-merge-sources       Keep sources separate

I have no sense of how many people are using these flags, or how you decided which to leave out. Googling around, I don't see much. Like it looks like --explicit-version was once used by fuchsia, but it doesn't look like they use it anymore?

Absent any more information, I would lean towards what you said (use cargo-vendor as a fallback), and hopefully if someone is relying on one of these flags, they can file an issue. Otherwise, we could assume they are not needed anymore.

Perhaps we could just add the flags here with the hidden attribute, and check if they are used and raise an error informing the user why the flag is not supported anymore, and maybe ask them to file an issue here?

@alexcrichton
Copy link
Member Author

Yeah it's just those flags, and I also don't have a great sense of how often they're used. I like the idea of hidden help flags that redirect users to file issues here, so I'll implement that.

@alexcrichton
Copy link
Member Author

Alright, that makes me comfortable with this PR, so...

@rfcbot fcp merge

@rfcbot
Copy link
Collaborator

rfcbot commented Apr 30, 2019

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

Concerns:

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.

@rfcbot rfcbot added proposed-final-comment-period An FCP proposal has started, but not yet signed off. disposition-merge FCP with intent to merge labels Apr 30, 2019
@nrc
Copy link
Member

nrc commented May 1, 2019

Do you have a sense of who and how many people use cargo vendor in its current state? What is the motivation for moving it into Cargo rather than maintaining it as an 'official' plugin?

@nrc
Copy link
Member

nrc commented May 1, 2019

@rfcbot concern why better to be built in?

(see above comment)

@alexcrichton
Copy link
Member Author

A good question! We talked about this briefly in the last cargo mtg but I'm realizing now I never actually wrote down the rationale, so now's a good a time as any!

I get the impression that usage of cargo vendor is quite common and is the defacto way to vendor dependencies (as opposed to cargo-local-registry). This is largely from the number of feature requests I've gotten on cargo-vendor over time and the support in maintaining it. Given that it's such an important part of our offline story as well it seemed like it was time to move it into Cargo proper to say that we support first-class vendoring rather than having to go through an external subcommand.

It's certainly possible to keep it as an external crate, but it comes with all the drawbacks of "oh now you have to cargo install it". To me it's just crossed the threshold of "useful enough to be bundled directly" sort of like cargo fix

@bors
Copy link
Contributor

bors commented May 3, 2019

☔ The latest upstream changes (presumably #6880) made this pull request unmergeable. Please resolve the merge conflicts.

@LegNeato
Copy link

LegNeato commented May 7, 2019

cargo-raze relies on -x when vendoring in: https://github.com/google/cargo-raze/blob/master/README.md

@cuviper
Copy link
Member

cuviper commented May 7, 2019

FWIW, I also found cargo-vendor useful and important enough to include in Red Hat's rust-toolset offering -- so far it's the only thing we add beyond the rust "extended tools" group. I would be happy to drop the extra package. :)

@vi
Copy link
Contributor

vi commented May 7, 2019

"oh now you have to cargo install it"

Can it be a rustup component? Or is rustup also met with some resistance?

Centril added a commit to Centril/rust that referenced this pull request Jun 12, 2019
Update cargo

Update cargo

19 commits in 545f354259be4e9745ea00a524c0e4c51df01aa6..807429e1b6da4e2ec52488ef2f59e77068c31e1f
2019-05-23 17:45:30 +0000 to 2019-06-11 14:06:10 +0000
- Stabilize publish-lockfile. (rust-lang/cargo#7026)
- change package cache lock message (rust-lang/cargo#7029)
- Fix documenting an example. (rust-lang/cargo#7023)
- Fix nonconcurrent tests (rust-lang/cargo#6900)
- Update git2 crates for libgit2 0.28 (rust-lang/cargo#7018)
- fix bunch of clippy warnings (rust-lang/cargo#7019)
- Ignore remap-path-prefix in metadata hash. (rust-lang/cargo#6966)
- Don't synthesize feature diretives for non-optional deps (rust-lang/cargo#7010)
- Handle pipelined tests of libraries (rust-lang/cargo#7008)
- Import the cargo-vendor subcommand into Cargo (rust-lang/cargo#6869)
- Remove unnecessary outlives bounds (rust-lang/cargo#7000)
- Catch filename output collisions in rustdoc. (rust-lang/cargo#6998)
- the testing SAT solver was messed up by a refactor (rust-lang/cargo#6995)
- Add some hints to the docs for `cfg()` targets (rust-lang/cargo#6990)
- Test the Resolver against the varisat Library (rust-lang/cargo#6980)
- Update changelog. (rust-lang/cargo#6984)
- Update cache-messages tracking issue. (rust-lang/cargo#6987)
- zsh: Add --all-targets option to cargo-check and cargo-build (rust-lang/cargo#6985)
- Fix typo (rust-lang/cargo#6982)
Centril added a commit to Centril/rust that referenced this pull request Jun 14, 2019
Update cargo

Update cargo

19 commits in 545f354259be4e9745ea00a524c0e4c51df01aa6..807429e1b6da4e2ec52488ef2f59e77068c31e1f
2019-05-23 17:45:30 +0000 to 2019-06-11 14:06:10 +0000
- Stabilize publish-lockfile. (rust-lang/cargo#7026)
- change package cache lock message (rust-lang/cargo#7029)
- Fix documenting an example. (rust-lang/cargo#7023)
- Fix nonconcurrent tests (rust-lang/cargo#6900)
- Update git2 crates for libgit2 0.28 (rust-lang/cargo#7018)
- fix bunch of clippy warnings (rust-lang/cargo#7019)
- Ignore remap-path-prefix in metadata hash. (rust-lang/cargo#6966)
- Don't synthesize feature diretives for non-optional deps (rust-lang/cargo#7010)
- Handle pipelined tests of libraries (rust-lang/cargo#7008)
- Import the cargo-vendor subcommand into Cargo (rust-lang/cargo#6869)
- Remove unnecessary outlives bounds (rust-lang/cargo#7000)
- Catch filename output collisions in rustdoc. (rust-lang/cargo#6998)
- the testing SAT solver was messed up by a refactor (rust-lang/cargo#6995)
- Add some hints to the docs for `cfg()` targets (rust-lang/cargo#6990)
- Test the Resolver against the varisat Library (rust-lang/cargo#6980)
- Update changelog. (rust-lang/cargo#6984)
- Update cache-messages tracking issue. (rust-lang/cargo#6987)
- zsh: Add --all-targets option to cargo-check and cargo-build (rust-lang/cargo#6985)
- Fix typo (rust-lang/cargo#6982)
bors added a commit to rust-lang/rust that referenced this pull request Jun 18, 2019
Update cargo

Update cargo

19 commits in 545f354259be4e9745ea00a524c0e4c51df01aa6..807429e1b6da4e2ec52488ef2f59e77068c31e1f
2019-05-23 17:45:30 +0000 to 2019-06-11 14:06:10 +0000
- Stabilize publish-lockfile. (rust-lang/cargo#7026)
- change package cache lock message (rust-lang/cargo#7029)
- Fix documenting an example. (rust-lang/cargo#7023)
- Fix nonconcurrent tests (rust-lang/cargo#6900)
- Update git2 crates for libgit2 0.28 (rust-lang/cargo#7018)
- fix bunch of clippy warnings (rust-lang/cargo#7019)
- Ignore remap-path-prefix in metadata hash. (rust-lang/cargo#6966)
- Don't synthesize feature diretives for non-optional deps (rust-lang/cargo#7010)
- Handle pipelined tests of libraries (rust-lang/cargo#7008)
- Import the cargo-vendor subcommand into Cargo (rust-lang/cargo#6869)
- Remove unnecessary outlives bounds (rust-lang/cargo#7000)
- Catch filename output collisions in rustdoc. (rust-lang/cargo#6998)
- the testing SAT solver was messed up by a refactor (rust-lang/cargo#6995)
- Add some hints to the docs for `cfg()` targets (rust-lang/cargo#6990)
- Test the Resolver against the varisat Library (rust-lang/cargo#6980)
- Update changelog. (rust-lang/cargo#6984)
- Update cache-messages tracking issue. (rust-lang/cargo#6987)
- zsh: Add --all-targets option to cargo-check and cargo-build (rust-lang/cargo#6985)
- Fix typo (rust-lang/cargo#6982)
@marsam marsam mentioned this pull request Sep 23, 2019
10 tasks
dtzWill pushed a commit to dtzWill/nixpkgs that referenced this pull request Oct 23, 2019
Cargo 1.37 imported `cargo-vendor` as built-in command [1]

[1] rust-lang/cargo#6869

(cherry picked from commit aed74e8)
@ehuss ehuss added this to the 1.37.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.