#cargo-build #cargo #build #windows #development #file-copy #file-lock

app cargo-run-copy

Like cargo run but runs from a copy to avoid file locking

1 unstable release

Uses new Rust 2024

new 0.1.0 Mar 9, 2025

#133 in Cargo plugins

Download history 107/week @ 2025-03-05

107 downloads per month

MIT/Apache

11KB
124 lines

cargo-run-copy

Crates.io Actions Status

Provides functionality similar to cargo run, but instead of directly executing the binary, it copies it to a different location before running.

This tool addresses a Windows limitation where files cannot be updated while they are running. This restriction prevents running another cargo run while one is already in progress, which can reduce development efficiency.

Use Case

For example, when developing a Model Context Protocol Server using the mcp-attr crate, you can test the MCP server in development by registering it with the MCP client using cargo run --manifest-path=<server's Cargo.toml> -- <server arguments>.

However, if the server is registered with multiple clients, you need to either disable or unregister the server from all clients before rebuilding (some MCP clients may not stop the server just by disabling it). This can be quite cumbersome.

By using cargo-run-copy instead of cargo run, you can rebuild even while the server is running, significantly improving the development experience. With many MCP clients, you can reflect changes by simply pressing the MCP server update button after modifying the source code.

How It Works

  1. Runs cargo build to generate the executable
  2. Calculates a hash value of the generated executable
  3. Copies the executable to the target/run-copy/<hash>/ directory
  4. Runs the copied executable with the specified arguments

This approach allows new builds to proceed without locking the original executable.

Installation

cargo install cargo-run-copy

Usage

Use cargo-run-copy instead of cargo run:

cargo-run-copy [cargo build options] -- [program arguments]

License

This project is dual licensed under Apache-2.0/MIT. See the two LICENSE-* files for details.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~2.5–3.5MB
~86K SLoC