cargo Verified current stable Not installed? Package Management

Cargo / Dry Run Update Dependencies

Dry Run Update Dependencies

Simulates an update for dependencies without modifying the Lock file.

$
Terminal
cargo update -n

When To Use

To evaluate the impact of updates before executing them in production environments.

Pro Tip

Review output closely; even dry runs can indicate substantial risks or improvements.

Terminal Output

Expected runtime feedback

Simulated preview
>
Output
\n     Updating dependencies\n      \n   Package              Version  Update designated  Dependency\n   ---------------------------------------\n   another-crate        1.0.3   1.1.0            required by my-crate\n   example-crate        0.5.1   0.6.0            optional by my-crate\n

Anatomy of Output

Understanding the result

Performing a dry run of updates... Dry Run Begin

No changes will be made.

→ Updating my_lib v1.0.0 -> v1.1.0 (will update) Simulated Dependency Update

Indicates which libraries would be updated.

→ Keeping my_old_lib v0.1.0 (no update) Simulated No Update

No changes required to this dependency.

Power User Variants

Optimized versions

cargo update --dry-run --verbose

Verbose output providing insight into the dry run.

cargo update -n --package my_lib

Dry run for a specific package.

Troubleshooting

Common pitfalls

error: command not found

Solution: Ensure the command is correct: `cargo update -n`.

error: Cargo.lock is corrupt

Solution: Delete and regenerate with `cargo generate-lockfile`.

error: unable to perform dry run

Solution: Check dependencies for any unmet constraints.

Command Breakdown

What each part is doing

cargo
Base Command
The executable that performs this operation. Here it runs Cargo before the shell applies any redirect operators.
-n
n| dry run
The value supplied for n| dry run.
-n
Command Option
Tool-specific option used by this command invocation.

How To Run

Execution path

  1. Step 1

    Run the command: `cargo update --dry-run`

  2. Step 2

    Verify the output for listed dependencies and their potential updates.

Alternative Approaches

Comparable commands in other tools

Alternative package management tools for the same job.