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

Upgrade dependency to specific version #177

Closed
jrobsonchase opened this issue Nov 16, 2017 · 6 comments · Fixed by #200
Closed

Upgrade dependency to specific version #177

jrobsonchase opened this issue Nov 16, 2017 · 6 comments · Fixed by #200

Comments

@jrobsonchase
Copy link

Pushing a dependency to the latest version isn't always the desired behavior. For example, if one of your crate's dependencies depends on an older version of error_chain than the latest, it can cause problems since you can end up with two incompatible versions of the generated types.

It would be nice to have an option to specify the version to upgrade (or even downgrade) to, either in the cargo-upgrade command, or in a new cargo-set-version command, preferably that would work for the entire workspace.

@ordian
Copy link
Collaborator

ordian commented Nov 16, 2017

@jechas01 I think you can already use cargo add <crate> --vers <vers> for this, though it wouldn't work with workspaces.

@jrobsonchase
Copy link
Author

jrobsonchase commented Nov 17, 2017 via email

@ordian
Copy link
Collaborator

ordian commented Nov 17, 2017

Yeah, we should probably document that: running cargo add <crate> will overwrite existing <crate> entry in Cargo.toml (with or w/o --vers flag).

@jrobsonchase
Copy link
Author

jrobsonchase commented Nov 17, 2017 via email

@bjgill
Copy link
Collaborator

bjgill commented Dec 15, 2017

That's an interesting point. I've also been using cargo upgrade with a large workspace. I've had the same problem you did, and have also found upgrading single dependencies more often than the complete set.

Maybe we should change the CLI to something like:

Usage:
    cargo upgrade [options]
    cargo upgrade [options] <dependency> [--vers <version>]

Here, the default would remain unchanged, but the experience of upgrading a single dependency would be better (no longer need a -d), and you would be able to specify a version (allowing us to short-circuit crates.io).

We'd probably want to deprecate the old way of specifying specific dependencies (-d --dependency) and warn the user if they use that format.

Thoughts? I shouldn't think this should be too difficult, so I might look at implementing this over the weekend.

@bjgill
Copy link
Collaborator

bjgill commented Feb 5, 2018

I'm starting to look at this now. It probably makes sense to try and stick as close as possible to cargo update. As such, I think I favour:

Usage:
    cargo upgrade [options]
    cargo upgrade [options] <dependency>... [--precise <PRECISE>]
    cargo upgrade (-h | --help)
    cargo upgrade (-V | --version)

Options:
    --all                       Upgrade all packages in the workspace.
    --precise PRECISE           Upgrade dependencies to exactly PRECISE.
    --manifest-path PATH        Path to the manifest to upgrade.
    --allow-prerelease          Include prerelease versions when fetching from crates.io (e.g.
                                '0.6.0-alpha'). Defaults to false.
    -h --help                   Show this help page.
    -V --version                Show version.

bjgill added a commit to bjgill/cargo-edit that referenced this issue Feb 11, 2018
Fixes killercup#177. If this flag is provided, all dependencies upgraded will be blindly
upgraded to the version specified.

Also, there has been substantial refactoring. The new `Manifests` and `Dependencies` structs now hold the logic for upgrade. This allows us to
commonise the cases of a single upgrade and full workspace upgrade quite
considerably. This should also make it fairly simple to extend to permit
providing a list of packages to confine upgrades to.

Also does some tidying up for the new `--precise` option. Most
significantly, we now have a test for this functionality.
@bjgill bjgill self-assigned this Feb 11, 2018
bors bot added a commit that referenced this issue Feb 16, 2018
200: Add `--precise` flag for cargo-upgrade  r=bjgill a=bjgill

Fixes #177. If this flag is provided, all dependencies upgraded will be blindly upgraded to the
version specified. Added a test for this new feature.

Also, there has been substantial refactoring. The new `Manifests` and `Dependencies` structs now
hold the logic for upgrade. This allows us to commonise the cases of a single and full
workspace upgrade quite considerably.

EDIT: this also fixes #182 (I'll open a new issue for alternate registries)
@bors bors bot closed this as completed in #200 Feb 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants