Adding feature-flags to `cargo publish` and `cargo package`
This change adds the `--features` and `--all-features` flags to the
above mentioned commands. This is to allow publishing of crates that
have certain feature requirements for compilation, without having to
rely on `--no-verify` which isn't good practise.
This PR adds two new fields `features` and `all_features` to both the
`PackageOpts` and `PublishOpts` and also adds the argument options
to the CLI commands.
Merging this feature will allow people to publish crates on crates.io
that require some feature flag to compile (or all?) without needing
to rely on not checking the package before uploading, potentially
resulting in less packaging errors and broken packages.
The old code used an unreliable method to detect if `cargo publish` was publishing to crates.io. This should work even if the `--index` flag is used.
Also includes a very minor rewording of an error message mentioning crates.io, even for alternative registries.
This change adds the `--features` and `--all-features` flags to the
above mentioned commands. This is to allow publishing of crates that
have certain feature requirements for compilation, without having to
rely on `--no-verify` which isn't good practise.
This PR adds two new fields `features` and `all_features` to both the
`PackageOpts` and `PublishOpts` and also adds the argument options
to the CLI commands.
Merging this feature will allow people to publish crates on crates.io
that require some feature flag to compile (or all?) without needing
to rely on not checking the package before uploading, potentially
resulting in less packaging errors and broken packages.
This commit fixes#6125 by ensuring that while we're extracting tarballs
or doing other synchronous work like grabbing file locks we're not
letting the timeout timers of each HTTP transfer keep ticking. This is
curl's default behavior (which we don't want in this scenario). Instead
the timeout logic is inlined directly and we manually account for the
synchronous work happening not counting towards timeout limits.
Closes#6125
This is something we probably should have added long long ago given the
number of network issues that arise over time. This adds a new
configuration setting for Cargo, `http.debug`, which activates curl's
`verbose` interface which prints out information like redirects and
headers flying back and forth. This is by default routed through Cargo's
normal debug logging facilities, meaning one way to use this could be:
CARGO_HTTP_DEBUG=true \
RUST_LOG=cargo::ops::registry \
cargo build
and you should get lots of nice verbose logs as a result! This should
hopefully make it much easier to remotely debug HTTP issues as we can in
theory do a lot less guessing and a lot more manual inspection.
This commit fixes publishing crates which contain locally renamed dependencies
to crates.io. Previously this lack of information meant that although we could
resolve the crate graph correctly it wouldn't work well with respect to optional
features and optional dependencies. The fix here is to persist this information
into the registry about the crate being renamed in `Cargo.toml`, allowing Cargo
to correctly deduce feature names as it does when it has `Cargo.toml` locally.
A dual side of this commit is to publish this information to crates.io. We'll
want to merge the associated PR (link to come soon) on crates.io first and make
sure that's deployed as well before we stabilize the crate renaming feature.
The index format is updated as well as part of this change. The `name` key for
dependencies is now unconditionally what was written in `Cargo.toml` as the
left-hand-side of the dependency specification. In other words this is the raw
crate name, but only for the local crate. A new key, `package`, is added to
dependencies (and it can be `None`). This key indicates the crates.io package is
being linked against, an represents the `package` key in `Cargo.toml`.
It's important to consider the interaction with older Cargo implementations
which don't support the `package` key in the index. In these situations older
Cargo binaries will likely fail to resolve entirely as the renamed name is
unlikely to exist on crates.io. For example the `futures` crate now has an
optional dependency with the name `futures01` which depends on an older version
of `futures` on crates.io. The string `futures01` will be listed in the index
under the `"name"` key, but no `futures01` crate exists on crates.io so older
Cargo will generate an error. If the crate does exist on crates.io, then even
weirder error messages will likely result.
Closes#5962
Fixesrust-lang/cargo#5717
low-speed-time was removed because the corresponding curl-option is already set via http.timeout.
removed unnecessary Option.
This commit updates the implementation of renamed dependencies to use the listed
name of a dependency in Cargo.toml for the name of the associated feature,
rather than using the package name. This'll allow disambiguating between
different packages of the same name and was the intention all along!
Closes#5753
Here's an attempt at a table to cover the different cases:
Feature
Old (must be in features table)
Continue
Namespaced (might be stray value)
In features table: Check that Crate dependency is in the list
-> Non-optional dependency: Bail [PREVIOUSLY: bailed for non-optional dependency]
-> Optional dependency: Insert feature of this name
-> Else: Bail [PREVIOUSLY: bailed for unknown dependency or feature]
Crate
Old (might be stray value)
Non-optional dependency: Bail
No dependency found: Bail
Namespaced
Non-optional dependency: Bail
No dependency found: Bail
CrateFeature
Old
No dependency found: Bail
Namespaced
No dependency found: Bail
This commit removes the `Source::for_path` constructor in favor of
`Workspace::load`. This prevents re-parsing manifests multiple times as Cargo
loads up as this can sometimes be an expensive operation. Instead the
`Workspace` now retains a cache of packages that can be updated as it goes
along. Finally, this should mean that we're only parsing path dependencies at
most once rather than multiple times.
Add an "-Z offline" flag to Cargo, altering it's dependency resolution behavior
This PR is implementation of the #4686 (without "Populating the global cache" feature)
Previously, .cargo/credentials looked like
```toml
token = "..."
[my-registry]
token = "..."
```
And was simply merged into the `registry` block of .cargo/config. This
meant that custom registry tokens were under
`registry.my-registry.token` rather than `registries.my-registry.token`
which is where the index was located, and that you couldn't have a
custom registry named `token` or it'd conflict with the token for the
default registry.
This commit changes things such that .cargo/credentials has the same
layout as .cargo/config, but only contains token values. For backwards
compatibility, we move `token` to `registry.token` when parsing.
This commit is the initial steps to migrate Cargo's error handling from the
`error-chain` crate to the `failure` crate. This is intended to be a low-cost
(in terms of diff) transition where possible so it's note "purely idiomatic
`failure` crate" just yet.
The `error-chain` dependency is dropped in this commit and Cargo now canonically
uses the `Error` type from the `failure` crate. The main last remnant of
`error-chain` is a custom local extension trait to use `chain_err` instead of
`with_context`. I'll try to follow up with a commit that renames this later but
I wanted to make sure everything worked first! (and `chain_err` is used
practically everywhere).
Some minor tweaks happened in the tests as I touched up a few error messages
here and there but overall the UI of Cargo should be exactly the same before and
after this commit.
Break crate-descriptions at char-, not byte-boundary, avoiding a panic
Fixes#4771. The basic panicking-problem could be fixed by truncating at `char`- instead of `byte`-boundary. This PR takes the long route and uses the unicode-width to always truncate at grapheme-boundary, which should be visually correct in more cases. It adds two extra (extremely common) dependencies to Cargo, though. I have no strong opinions if this is worth it.
While truncating the descriptions, we now also take the length of the names-column into account, including margin, run a little shorter, and have them all of the same total true length.
Before
```
$ cargo search serde
serde = "1.0.23" # A generic serialization/deserialization framework
serde_json = "1.0.7" # A JSON serialization file format
serde_derive_internals = "0.17.0" # AST representation used by Serde derive macros. Unstable.
serde_yaml = "0.7.3" # YAML support for Serde
serde_derive = "1.0.23" # Macros 1.1 implementation of #[derive(Serialize, Deserialize)]
serde_test = "1.0.23" # Token De/Serializer for testing De/Serialize implementations
serde_bytes = "0.10.2" # Optimized handling of `&[u8]` and `Vec<u8>` for Serde
serde_millis = "0.1.1" # A serde wrapper that stores integer millisecond value for timestamps and durations (used similarly to serde_bytes)
serde_codegen_internals = "0.14.2" # AST representation used by Serde codegen. Unstable.
courier = "0.3.1" # Utility to make it easier to send and receive data when using the Rocket framework.
... and 275 crates more (use --limit N to see more)
```
After
```
$ cargo search serde
serde = "1.0.23" # A generic serialization/deserialization framework
serde_json = "1.0.7" # A JSON serialization file format
serde_derive_internals = "0.17.0" # AST representation used by Serde derive macros. Unstable.
serde_yaml = "0.7.3" # YAML support for Serde
serde_derive = "1.0.23" # Macros 1.1 implementation of #[derive(Serialize, Deserialize)]
serde_test = "1.0.23" # Token De/Serializer for testing De/Serialize implementations
serde_bytes = "0.10.2" # Optimized handling of `&[u8]` and `Vec<u8>` for Serde
serde_millis = "0.1.1" # A serde wrapper that stores integer millisecond value for …
serde_codegen_internals = "0.14.2" # AST representation used by Serde codegen. Unstable.
courier = "0.3.1" # Utility to make it easier to send and receive data when using …
... and 275 crates more (use --limit N to see more)
```