• Stars
    star
    3,079
  • Rank 14,617 (Top 0.3 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 9 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A utility for managing cargo dependencies from the command line.

cargo edit

This tool extends Cargo to allow you to add, remove, and upgrade dependencies by modifying your Cargo.toml file from the command line.

Currently available subcommands:

Build Status Build Status Build status Coverage Status crates.io Join the chat at https://gitter.im/cargo-edit/Lobby

Installation

Packaging status

Ensure that you have a fairly recent version of rust/cargo installed. On Ubuntu you would also need to install libssl-dev and pkg-config packages.

$ cargo install cargo-edit

If you wish to use a bundled version of openssl:

$ cargo install cargo-edit --features vendored-openssl

Compiler support: requires rustc 1.44+

(Please check cargo's documentation to learn how cargo install works and how to set up your system so it finds binaries installed by cargo.)

Install a sub-set of the commands with cargo install -f --no-default-features --features "<COMMANDS>", where <COMMANDS> is a space-separated list of commands; i.e. add rm upgrade for the full set.

Available Subcommands

cargo add

cargo add is now integrated into cargo as of v1.62. If you want access in older versions of cargo, you'll need to install cargo-edit v0.9 or earlier.

Known differences from cargo-edit v0.9.1

  • cargo add <path> is unsupported, instead use cargo add --path <path>
  • cargo add <crate> +<feature> is unsupported, instead use cargo add <crate> -F <feature>
    • If adding multiple crates, qualify the feature like cargo add serde -F serde/derive serde_json
    • See rust-lang/cargo#10809

cargo rm

cargo rm is now integrated into cargo as of v1.66. If you want access in older versions of cargo, you'll need to install cargo-edit v0.11 or earlier.

cargo upgrade

Upgrade dependencies in your Cargo.toml to their latest versions.

To specify a version to upgrade to, provide the dependencies in the <crate name>@<version> format, e.g. cargo upgrade -p docopt@~0.9.0 -p serde@>=0.9,<2.0.

This command differs from cargo update, which updates the dependency versions recorded in the local lock file (Cargo.lock).

Examples

# Upgrade all dependencies for the current crate
$ cargo upgrade
# Upgrade docopt (to ~0.9) and serde (to >=0.9,<2.0)
$ cargo upgrade -p docopt@~0.9 -p serde@>=0.9,<2.0
# Upgrade all dependencies except docopt and serde
$ cargo upgrade --exclude docopt --exclude serde

Usage

$ cargo-upgrade upgrade --help
Upgrade dependency version requirements in Cargo.toml manifest files

Usage: cargo upgrade [OPTIONS]

Options:
      --dry-run               Print changes to be made without making them
      --manifest-path <PATH>  Path to the manifest to upgrade
      --rust-version <VER>    Override `rust-version`
      --ignore-rust-version   Ignore `rust-version` specification in packages
      --offline               Run without accessing the network
      --locked                Require `Cargo.toml` to be up to date
  -v, --verbose...            Use verbose output
  -Z <FLAG>                   Unstable (nightly-only) flags
  -h, --help                  Print help
  -V, --version               Print version

Version:
      --compatible [<allow|ignore>]    Upgrade to latest compatible version [default: allow]
  -i, --incompatible [<allow|ignore>]  Upgrade to latest incompatible version [default: ignore]
      --pinned [<allow|ignore>]        Upgrade pinned to latest incompatible version [default:
                                       ignore]

Dependencies:
  -p, --package <PKGID[@<VERSION>]>  Crate to be upgraded
      --exclude <PKGID>              Crates to exclude and not upgrade
      --recursive [<true|false>]     Recursively update locked dependencies

cargo set-version

Set the version in your Cargo.toml.

Examples

# Set the version to the version 1.0.0
$ cargo set-version 1.0.0
# Bump the version to the next major
$ cargo set-version --bump major
# Bump version to the next minor
$ cargo set-version --bump minor
# Bump version to the next patch
$ cargo set-version --bump patch

Usage

$ cargo-set-version set-version --help
Change a package's version in the local manifest file (i.e. Cargo.toml)

Usage: cargo set-version [OPTIONS] [TARGET]

Arguments:
  [TARGET]  Version to change manifests to

Options:
      --bump <BUMP>           Increment manifest version
  -m, --metadata <METADATA>   Specify the version metadata field (e.g. a wrapped libraries version)
      --manifest-path <PATH>  Path to the manifest to upgrade
  -p, --package <PKGID>       Package id of the crate to change the version of
      --all                   [deprecated in favor of `--workspace`]
      --workspace             Modify all packages in the workspace
      --dry-run               Print changes to be made without making them
      --exclude <EXCLUDE>     Crates to exclude and not modify
      --offline               Run without accessing the network
      --locked                Require `Cargo.toml` to be up to date
  -Z <FLAG>                   Unstable (nightly-only) flags
  -h, --help                  Print help
  -V, --version               Print version

For more on metadata, see the semver crate's documentation.

Related Cargo Commands

Contribution

Thanks for your interest - we gratefully welcome contributions.

Questions can be asked in issues, or on Gitter.

To help us help you get pull requests merged quickly and smoothly, open an issue before submitted large changes. Please keep the contents of pull requests and commits short. Commit messages should include the intent of the commit.

cargo-edit has a moderately comprehensive test suite. Contributions that add/improve tests are awesome. Please add tests for every change.

cargo-edit uses rustfmt for formatting and clippy for linting.

License

Apache-2.0/MIT

More Repositories

1

quicli

Quickly build cool CLI apps in Rust.
Rust
544
star
2

trpl-ebook

UNMAINTAINED
Rust
479
star
3

scribbles

Some notes on various topics.
Nix
63
star
4

wasm-experiments

Please don't use this! Check out this instead:
JavaScript
61
star
5

convey

A Rust create for outputting information and log messages for humans and machines
Rust
39
star
6

react-prop-schema

A library to validate a data structure and create fake content at the same time. Works great with React.js.
CoffeeScript
39
star
7

grock

Grock converts your nicely commented code into a gorgeous documentation where comments and code live happily next to each other.
CoffeeScript
38
star
8

cycle-webpack-starter

Boilerplate for building ES6 web apps using Cycle.js
JavaScript
38
star
9

static-filez

Build compressed archives for static files and serve them over HTTP
Rust
35
star
10

codenamer

Quickly generate a code name for your new project, release, pony, car or variety of wine!
JavaScript
33
star
11

english-lint

Find common stylistic problems in english texts. Works well for technical or scientific documents.
Rust
32
star
12

report-visualizer

Server-less web app to display data gathered by reporter-app.com
CoffeeScript
28
star
13

waltz

Extract code files from Markdown
Rust
27
star
14

rust-cheat-sheet

Rust
18
star
15

jekyll-theme-scribbles

A minimalistic Jekyll theme recreating the look of plain Markdown file (with some extras)
SCSS
17
star
16

a-range

Write quick and explict ranges in Rust
Rust
15
star
17

hsl-rs

Convert RGB⇄HSL Colors
Rust
14
star
18

a1

A theme for an old version Redmine. Based on the original A1, but adds a media query based mobile layout.
JavaScript
13
star
19

assert_tokens_eq

Like Rust's built-in assert_eq macro, but for token streams. Passes them through rustfmt, and shows a pretty diff
Rust
13
star
20

simd-utf8-check

Rust
13
star
21

presentation-declarative-programming-in-rust

CSS
11
star
22

zfs-gui-thing

A thing to GUI up your `zfs list`
Rust
11
star
23

rust-docstrings

Rust
11
star
24

mctrevor

CMS based on Sir Trevor JS – Proof of Concept as of Jan 2014
CoffeeScript
10
star
25

snafu-cli-debug

Implement Rust's Debug trait on Snafu errors for pretty CLI output
Rust
10
star
26

testing-rust

7
star
27

silicon-zucchini

Generate glorious and amazing static sites
JavaScript
6
star
28

presentation-rust-approach

CSS
6
star
29

vscode-why-in-the-git

A VSCode extension that gives you a command to show the commit message corresponding to the latest change to the line your cursor is on.
TypeScript
6
star
30

rustfest-idiomatic-libs

Talk for RustFest 2017 in Kyiv (http://2017.rustfest.eu/talks/#writing-idiomatic-libraries-in-rust)
CSS
5
star
31

timebomb

A simple timeout for your unit tests.
Rust
4
star
32

angular-epicmodel

A model/collection service for Angular.js
CoffeeScript
4
star
33

conescy

Conescy is a tiny CMS built with Django I started some time ago for personal needs.
Python
4
star
34

sortStringToSql

Node Module. Convert Sort Expression to SQL that can be used in 'ORDER BY' statement, e.g. '-aired,id' -> 'aird DESC NULLS LAST, id ASC NULLS LAST'.
JavaScript
3
star
35

olive-dolphin-prophecy

Kotlin
3
star
36

sublime-scheme-shiny

Sublime Text Color Scheme based on MarkdownEditing
3
star
37

vibrant-rs

Extract vibrant colors from an image
Rust
3
star
38

presentation-diesel-adventure

CSS
3
star
39

marmalade

Rust
3
star
40

clap-man-demo

Rust
3
star
41

flabs-file-dump

Displays pictures and stuff in an awesome way. (License: CC-BY-SA)
PHP
3
star
42

angular-notifications

Notification service for angular offering alerts and confirms supporting cordova
JavaScript
3
star
43

async-read-progress

Extension traits for inspecting AsyncRead progress.
Rust
2
star
44

macromusic

Rust
2
star
45

atric

Amazon Trade In Price Check
CoffeeScript
2
star
46

presentation-rust-rhein-main

CSS
2
star
47

rust-sortStringToSql

Rust Version. Convert Sort Expression to SQL that can be used in 'ORDER BY' statement, e.g. '-aired,id' -> 'aird DESC NULLS LAST, id ASC NULLS LAST'.
Rust
2
star
48

tweet-a-comment

Implement 'comments' on static pages using tweets. Based on jQuery. ##DOES NOT WORK##
JavaScript
2
star
49

sensors-gui-thing

Rust
1
star
50

presentation-rust-fb-dev-circle

CSS
1
star
51

schinken

Rust
1
star
52

docker-ubuntu-rails

Docker Image for Rails Project based on Ubuntu 14.10
1
star
53

jekyll-theme-rustguides

CSS
1
star
54

pascastle

Shell
1
star
55

is_anagram

Rust
1
star
56

ghReleases2Changelog

Write Github releases to changelog file
JavaScript
1
star
57

deterministic2

CSS
1
star
58

presentation-macro-madness

CSS
1
star
59

lapis-benchmarks

Openresty/Lapis Implementation of the TechEmpower Framework Benchmarks
Lua
1
star
60

presentation-hello-rust-gbg

CSS
1
star