|new 0.2.7||Nov 25, 2021|
|0.2.6||Nov 25, 2021|
|0.2.5||Oct 27, 2021|
|0.2.3||Aug 24, 2021|
|0.1.3||May 19, 2021|
#34 in Cargo plugins
49 downloads per month
A CLI tool that allows you to create a new rust project in a temporary directory with already installed dependencies.
Requires Rust 1.51.
cargo install cargo-temp
Create a new temporary project:
With no additional dependencies:
With multiple dependencies:
cargo-temp rand tokio
When specifying a version:
Using the cargo's comparison requirements:
You can add repositories to your
If you have some problems to add a dependency over SSH, please refer to this: Support SSH Git URLs. If it doesn't help, please fill an issue.
- Without package name
To choose a branch or a revision:
Without a branch or a revision, cargo will use the default branch of the repository.
You can add features to a dependency with
A dependency with feature
A dependency with version and feature
A repository with branch and feature
Without specifying package name
If you want to add multiple features you can do it with
+, like this:
If you change your mind and decide to keep the project you can just delete the
TO_DELETE file and the directory will not be deleted when the shell or the
You can create a git worktree from the current repository using:
This will create a new working tree at the current HEAD. You can specify a branch like this:
cargo-temp --worktree <branch>
When exiting the shell (or your editor) the working tree will be cleaned up.
git worktree prune.
If you want to create a temporary project from a Git repository, you can use the
--git option with the repository's URL:
cargo-temp --git <url>
Cargo-temp truncates the history to the last commit by default. You can change this behavior in the config file:
- You can choose how many commits will stay in the history.
This will leave the 3 last commits of the history.
git_repo_depth = 3
- If you do not want to truncate the history, you can set the
git_repo_depth = false
git_repo_depth = true is the same as the default behavior.
The config file is located at
When you run
cargo-temp for the first time it will be created automatically.
We use the XDG system for both Linux and OSX
and the Known Folder system on Windows.
The path where the temporary projects are created. Set on the cache directory by default.
temporary_project_dir = "/home/name/.cache/cargo-temp/"
Cargo's target directory override.
This setting is unset by default and will be ignored if the
environment variable is already set.
cargo_target_dir = "/home/name/repos/tmp"
You can use
editor to start an IDE instead of a shell
editor_args to provide its arguments. These settings are unset by default.
Example to run VS Code on Unix
editor = "/usr/bin/code" editor_args = [ "--wait", "--new-window" ]
Example to run VS Code on Windows
editor = "C:\\Program Files\\Microsoft VS Code\\Code.exe" editor_args = [ "--wait", "--new-window" ]
By default, cargo-temp will use the default cargo VCS for your projects (which
is normally git), you can change that in the config file with the
vcs = "pijul"
The possible values are
--vcs value will be passed as is to cargo.
You can spawn subprocess along your temporary shell like this:
[[subprocess]] command = "alacritty -e cargo watch -x run" foreground = false
command field is a shell command like
foreground field allows to run the program in foreground instead of
working_diroverrides the default working directory. The default is to use the temporary directory that has been created.
keep_on_exitis used to keep the process alive after exiting the shell. The default is to kill the process when the shell exits. This setting doesn't work with foreground process.
stderrsettings allows enabling or disabling outputs. With a background process, the default will be false, with a foreground process, the default will be true. The
stdinsetting doesn't exist since it's always disabled.
inherit_handlesallows handles inheritance - If this parameter is true, each inheritable handle in the calling process is inherited by the new process. If the parameter is false, the handles are not inherited (see CreateProcessW).
[[subprocess]] command = "cargo run" foreground = true [[subprocess]] command = "firefox" foreground = false
[[subprocess]] command = "cargo.exe run" foreground = true [[subprocess]] command = "firefox.exe" foreground = false