diff --git a/src/bin/cargo/commands/add.rs b/src/bin/cargo/commands/add.rs
index 30956b00479..da821f328bd 100644
--- a/src/bin/cargo/commands/add.rs
+++ b/src/bin/cargo/commands/add.rs
@@ -87,6 +87,7 @@ Example uses:
- Depend on crates with the same name from different registries"),
])
.arg_manifest_path_without_unsupported_path_tip()
+ .arg_lockfile_path()
.arg_package("Package to modify")
.arg_ignore_rust_version()
.arg_dry_run("Don't actually write the manifest")
diff --git a/src/bin/cargo/commands/bench.rs b/src/bin/cargo/commands/bench.rs
index c79d7cb350d..1f4c8df80ea 100644
--- a/src/bin/cargo/commands/bench.rs
+++ b/src/bin/cargo/commands/bench.rs
@@ -50,6 +50,7 @@ pub fn cli() -> Command {
.arg_unit_graph()
.arg_timings()
.arg_manifest_path()
+ .arg_lockfile_path()
.arg_ignore_rust_version()
.after_help(color_print::cstr!(
"Run `cargo help bench>` for more detailed information.\n"
diff --git a/src/bin/cargo/commands/build.rs b/src/bin/cargo/commands/build.rs
index 26f7af31609..86d477ccac2 100644
--- a/src/bin/cargo/commands/build.rs
+++ b/src/bin/cargo/commands/build.rs
@@ -39,6 +39,7 @@ pub fn cli() -> Command {
.arg_unit_graph()
.arg_timings()
.arg_manifest_path()
+ .arg_lockfile_path()
.arg_ignore_rust_version()
.after_help(color_print::cstr!(
"Run `cargo help build>` for more detailed information.\n"
diff --git a/src/bin/cargo/commands/check.rs b/src/bin/cargo/commands/check.rs
index 56f274effba..66f378c3e90 100644
--- a/src/bin/cargo/commands/check.rs
+++ b/src/bin/cargo/commands/check.rs
@@ -36,6 +36,7 @@ pub fn cli() -> Command {
.arg_unit_graph()
.arg_timings()
.arg_manifest_path()
+ .arg_lockfile_path()
.arg_ignore_rust_version()
.after_help(color_print::cstr!(
"Run `cargo help check>` for more detailed information.\n"
diff --git a/src/bin/cargo/commands/clean.rs b/src/bin/cargo/commands/clean.rs
index 1764c0bca1c..d9414b4d17d 100644
--- a/src/bin/cargo/commands/clean.rs
+++ b/src/bin/cargo/commands/clean.rs
@@ -19,6 +19,7 @@ pub fn cli() -> Command {
.arg_target_triple("Target triple to clean output for")
.arg_target_dir()
.arg_manifest_path()
+ .arg_lockfile_path()
.arg_dry_run("Display what would be deleted without deleting anything")
.args_conflicts_with_subcommands(true)
.subcommand(
diff --git a/src/bin/cargo/commands/doc.rs b/src/bin/cargo/commands/doc.rs
index 2603b3cb777..6707364d946 100644
--- a/src/bin/cargo/commands/doc.rs
+++ b/src/bin/cargo/commands/doc.rs
@@ -39,6 +39,7 @@ pub fn cli() -> Command {
.arg_unit_graph()
.arg_timings()
.arg_manifest_path()
+ .arg_lockfile_path()
.arg_ignore_rust_version()
.after_help(color_print::cstr!(
"Run `cargo help doc>` for more detailed information.\n"
diff --git a/src/bin/cargo/commands/fetch.rs b/src/bin/cargo/commands/fetch.rs
index f60ed61b854..2fdba80baf8 100644
--- a/src/bin/cargo/commands/fetch.rs
+++ b/src/bin/cargo/commands/fetch.rs
@@ -9,6 +9,7 @@ pub fn cli() -> Command {
.arg_silent_suggestion()
.arg_target_triple("Fetch dependencies for the target triple")
.arg_manifest_path()
+ .arg_lockfile_path()
.after_help(color_print::cstr!(
"Run `cargo help fetch>` for more detailed information.\n"
))
diff --git a/src/bin/cargo/commands/fix.rs b/src/bin/cargo/commands/fix.rs
index 8190cf07e95..e44980d1330 100644
--- a/src/bin/cargo/commands/fix.rs
+++ b/src/bin/cargo/commands/fix.rs
@@ -1,6 +1,6 @@
use crate::command_prelude::*;
-
use cargo::core::Workspace;
+
use cargo::ops;
pub fn cli() -> Command {
@@ -54,6 +54,7 @@ pub fn cli() -> Command {
.arg_target_dir()
.arg_timings()
.arg_manifest_path()
+ .arg_lockfile_path()
.arg_ignore_rust_version()
.after_help(color_print::cstr!(
"Run `cargo help fix>` for more detailed information.\n"
@@ -71,8 +72,13 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
// Unlike other commands default `cargo fix` to all targets to fix as much
// code as we can.
let root_manifest = args.root_manifest(gctx)?;
+
+ // Can't use workspace() to avoid using -Zavoid-dev-deps (if passed)
let mut ws = Workspace::new(&root_manifest, gctx)?;
ws.set_resolve_honors_rust_version(args.honor_rust_version());
+ let lockfile_path = args.lockfile_path(gctx)?;
+ ws.set_requested_lockfile_path(lockfile_path.clone());
+
let mut opts = args.compile_options(gctx, mode, Some(&ws), ProfileChecking::LegacyTestOnly)?;
if !opts.filter.is_specific() {
@@ -92,6 +98,7 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
allow_no_vcs: args.flag("allow-no-vcs"),
allow_staged: args.flag("allow-staged"),
broken_code: args.flag("broken-code"),
+ requested_lockfile_path: lockfile_path,
},
)?;
Ok(())
diff --git a/src/bin/cargo/commands/generate_lockfile.rs b/src/bin/cargo/commands/generate_lockfile.rs
index a2ddac61dd9..3ad858daaa7 100644
--- a/src/bin/cargo/commands/generate_lockfile.rs
+++ b/src/bin/cargo/commands/generate_lockfile.rs
@@ -7,6 +7,7 @@ pub fn cli() -> Command {
.about("Generate the lockfile for a package")
.arg_silent_suggestion()
.arg_manifest_path()
+ .arg_lockfile_path()
.arg_ignore_rust_version_with_help(
"Ignore `rust-version` specification in packages (unstable)",
)
diff --git a/src/bin/cargo/commands/metadata.rs b/src/bin/cargo/commands/metadata.rs
index 83232ef47f2..0b98d50a114 100644
--- a/src/bin/cargo/commands/metadata.rs
+++ b/src/bin/cargo/commands/metadata.rs
@@ -1,6 +1,7 @@
-use crate::command_prelude::*;
use cargo::ops::{self, OutputMetadataOptions};
+use crate::command_prelude::*;
+
pub fn cli() -> Command {
subcommand("metadata")
.about(
@@ -26,6 +27,7 @@ pub fn cli() -> Command {
.arg_silent_suggestion()
.arg_features()
.arg_manifest_path()
+ .arg_lockfile_path()
.after_help(color_print::cstr!(
"Run `cargo help metadata>` for more detailed information.\n"
))
diff --git a/src/bin/cargo/commands/package.rs b/src/bin/cargo/commands/package.rs
index 42b3ac3d03d..251fa286ec5 100644
--- a/src/bin/cargo/commands/package.rs
+++ b/src/bin/cargo/commands/package.rs
@@ -37,6 +37,7 @@ pub fn cli() -> Command {
.arg_target_dir()
.arg_parallel()
.arg_manifest_path()
+ .arg_lockfile_path()
.after_help(color_print::cstr!(
"Run `cargo help package>` for more detailed information.\n"
))
diff --git a/src/bin/cargo/commands/pkgid.rs b/src/bin/cargo/commands/pkgid.rs
index 72abbfc0788..5fcf85b8fd9 100644
--- a/src/bin/cargo/commands/pkgid.rs
+++ b/src/bin/cargo/commands/pkgid.rs
@@ -10,6 +10,7 @@ pub fn cli() -> Command {
.arg_silent_suggestion()
.arg_package("Argument to get the package ID specifier for")
.arg_manifest_path()
+ .arg_lockfile_path()
.after_help(color_print::cstr!(
"Run `cargo help pkgid>` for more detailed information.\n"
))
diff --git a/src/bin/cargo/commands/publish.rs b/src/bin/cargo/commands/publish.rs
index 3b497e1ed12..df1c4654ffe 100644
--- a/src/bin/cargo/commands/publish.rs
+++ b/src/bin/cargo/commands/publish.rs
@@ -24,6 +24,7 @@ pub fn cli() -> Command {
.arg_target_triple("Build for the target triple")
.arg_target_dir()
.arg_manifest_path()
+ .arg_lockfile_path()
.after_help(color_print::cstr!(
"Run `cargo help publish>` for more detailed information.\n"
))
diff --git a/src/bin/cargo/commands/remove.rs b/src/bin/cargo/commands/remove.rs
index b5695e59937..e74f53d6442 100644
--- a/src/bin/cargo/commands/remove.rs
+++ b/src/bin/cargo/commands/remove.rs
@@ -51,6 +51,7 @@ pub fn cli() -> clap::Command {
])
.arg_package("Package to remove from")
.arg_manifest_path()
+ .arg_lockfile_path()
.after_help(color_print::cstr!(
"Run `cargo help remove>` for more detailed information.\n"
))
diff --git a/src/bin/cargo/commands/run.rs b/src/bin/cargo/commands/run.rs
index 74eb1450bd0..c9e59770a28 100644
--- a/src/bin/cargo/commands/run.rs
+++ b/src/bin/cargo/commands/run.rs
@@ -38,6 +38,7 @@ pub fn cli() -> Command {
.arg_target_triple("Build for the target triple")
.arg_target_dir()
.arg_manifest_path()
+ .arg_lockfile_path()
.arg_ignore_rust_version()
.arg_unit_graph()
.arg_timings()
diff --git a/src/bin/cargo/commands/rustc.rs b/src/bin/cargo/commands/rustc.rs
index 2f52c6b5926..999f8d64c39 100644
--- a/src/bin/cargo/commands/rustc.rs
+++ b/src/bin/cargo/commands/rustc.rs
@@ -52,6 +52,7 @@ pub fn cli() -> Command {
.arg_unit_graph()
.arg_timings()
.arg_manifest_path()
+ .arg_lockfile_path()
.arg_ignore_rust_version()
.after_help(color_print::cstr!(
"Run `cargo help rustc>` for more detailed information.\n"
diff --git a/src/bin/cargo/commands/rustdoc.rs b/src/bin/cargo/commands/rustdoc.rs
index 6535ca405c6..f9c290bf5a0 100644
--- a/src/bin/cargo/commands/rustdoc.rs
+++ b/src/bin/cargo/commands/rustdoc.rs
@@ -45,6 +45,7 @@ pub fn cli() -> Command {
.arg_unit_graph()
.arg_timings()
.arg_manifest_path()
+ .arg_lockfile_path()
.arg_ignore_rust_version()
.after_help(color_print::cstr!(
"Run `cargo help rustdoc>` for more detailed information.\n"
diff --git a/src/bin/cargo/commands/test.rs b/src/bin/cargo/commands/test.rs
index c2657a78f05..73c3505100c 100644
--- a/src/bin/cargo/commands/test.rs
+++ b/src/bin/cargo/commands/test.rs
@@ -60,6 +60,7 @@ pub fn cli() -> Command {
.arg_unit_graph()
.arg_timings()
.arg_manifest_path()
+ .arg_lockfile_path()
.arg_ignore_rust_version()
.after_help(color_print::cstr!(
"Run `cargo help test>` for more detailed information.\n\
diff --git a/src/bin/cargo/commands/tree.rs b/src/bin/cargo/commands/tree.rs
index 6d83f8e8e95..b0f35370ebc 100644
--- a/src/bin/cargo/commands/tree.rs
+++ b/src/bin/cargo/commands/tree.rs
@@ -95,6 +95,7 @@ pub fn cli() -> Command {
Pass `all` to include all targets.",
)
.arg_manifest_path()
+ .arg_lockfile_path()
.after_help(color_print::cstr!(
"Run `cargo help tree>` for more detailed information.\n"
))
diff --git a/src/bin/cargo/commands/update.rs b/src/bin/cargo/commands/update.rs
index 492be07c783..4c19bcb270d 100644
--- a/src/bin/cargo/commands/update.rs
+++ b/src/bin/cargo/commands/update.rs
@@ -49,6 +49,7 @@ pub fn cli() -> Command {
.help_heading(heading::PACKAGE_SELECTION),
)
.arg_manifest_path()
+ .arg_lockfile_path()
.arg_ignore_rust_version_with_help(
"Ignore `rust-version` specification in packages (unstable)",
)
diff --git a/src/bin/cargo/commands/vendor.rs b/src/bin/cargo/commands/vendor.rs
index efa1f1bb7b6..96b30676732 100644
--- a/src/bin/cargo/commands/vendor.rs
+++ b/src/bin/cargo/commands/vendor.rs
@@ -37,6 +37,7 @@ pub fn cli() -> Command {
.arg(unsupported("only-git-deps"))
.arg(unsupported("disallow-duplicates"))
.arg_manifest_path()
+ .arg_lockfile_path()
.after_help(color_print::cstr!(
"Run `cargo help vendor>` for more detailed information.\n"
))
diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs
index 4ac8777bd62..6f1770b0f72 100644
--- a/src/cargo/core/workspace.rs
+++ b/src/cargo/core/workspace.rs
@@ -103,6 +103,9 @@ pub struct Workspace<'gctx> {
// file. This is set for `cargo install` without `--locked`.
ignore_lock: bool,
+ /// Requested path of the lockfile (i.e. passed as the cli flag)
+ requested_lockfile_path: Option,
+
/// The resolver behavior specified with the `resolver` field.
resolve_behavior: ResolveBehavior,
resolve_honors_rust_version: bool,
@@ -237,6 +240,7 @@ impl<'gctx> Workspace<'gctx> {
require_optional_deps: true,
loaded_packages: RefCell::new(HashMap::new()),
ignore_lock: false,
+ requested_lockfile_path: None,
resolve_behavior: ResolveBehavior::V1,
resolve_honors_rust_version: false,
custom_metadata: None,
@@ -647,6 +651,31 @@ impl<'gctx> Workspace<'gctx> {
self
}
+ /// Returns the directory where the lockfile is in.
+ pub fn lock_root(&self) -> Filesystem {
+ if let Some(requested) = self.requested_lockfile_path.as_ref() {
+ return Filesystem::new(
+ requested
+ .parent()
+ .expect("Lockfile path can't be root")
+ .to_owned(),
+ );
+ }
+ self.default_lock_root()
+ }
+
+ fn default_lock_root(&self) -> Filesystem {
+ if self.root_maybe().is_embedded() {
+ self.target_dir()
+ } else {
+ Filesystem::new(self.root().to_owned())
+ }
+ }
+
+ pub fn set_requested_lockfile_path(&mut self, path: Option) {
+ self.requested_lockfile_path = path;
+ }
+
/// Get the lowest-common denominator `package.rust-version` within the workspace, if specified
/// anywhere
pub fn rust_version(&self) -> Option<&RustVersion> {
diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs
index 459e780f32f..f879f764101 100644
--- a/src/cargo/ops/cargo_package.rs
+++ b/src/cargo/ops/cargo_package.rs
@@ -6,6 +6,7 @@ use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::task::Poll;
+use super::RegistryOrIndex;
use crate::core::compiler::{BuildConfig, CompileMode, DefaultExecutor, Executor};
use crate::core::dependency::DepKind;
use crate::core::manifest::Target;
@@ -13,6 +14,7 @@ use crate::core::resolver::CliFeatures;
use crate::core::resolver::HasDevUnits;
use crate::core::{Feature, PackageIdSpecQuery, Shell, Verbosity, Workspace};
use crate::core::{Package, PackageId, PackageSet, Resolve, SourceId};
+use crate::ops::lockfile::LOCKFILE_NAME;
use crate::sources::registry::index::{IndexPackage, RegistryDependency};
use crate::sources::{PathSource, SourceConfigMap, CRATES_IO_REGISTRY};
use crate::util::cache_lock::CacheLockMode;
@@ -32,8 +34,6 @@ use tar::{Archive, Builder, EntryType, Header, HeaderMode};
use tracing::debug;
use unicase::Ascii as UncasedAscii;
-use super::RegistryOrIndex;
-
#[derive(Clone)]
pub struct PackageOpts<'gctx> {
pub gctx: &'gctx GlobalContext,
@@ -248,7 +248,12 @@ pub fn package(ws: &Workspace<'_>, opts: &PackageOpts<'_>) -> CargoResult,
}
pub fn fix(
@@ -121,6 +122,7 @@ pub fn fix(
}
let mut ws = Workspace::new(&root_manifest, gctx)?;
ws.set_resolve_honors_rust_version(Some(original_ws.resolve_honors_rust_version()));
+ ws.set_requested_lockfile_path(opts.requested_lockfile_path.clone());
// Spin up our lock server, which our subprocesses will use to synchronize fixes.
let lock_server = LockServer::new()?;
diff --git a/src/cargo/ops/lockfile.rs b/src/cargo/ops/lockfile.rs
index 162cb6031bd..d865a7186f6 100644
--- a/src/cargo/ops/lockfile.rs
+++ b/src/cargo/ops/lockfile.rs
@@ -6,14 +6,16 @@ use crate::util::Filesystem;
use anyhow::Context as _;
+pub const LOCKFILE_NAME: &str = "Cargo.lock";
+
#[tracing::instrument(skip_all)]
pub fn load_pkg_lockfile(ws: &Workspace<'_>) -> CargoResult
--frozen
Equivalent to specifying both --locked and --offline.
+
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
+
### Common Options
diff --git a/src/doc/src/commands/cargo-bench.md b/src/doc/src/commands/cargo-bench.md
index d48e164e956..b23127fb98a 100644
--- a/src/doc/src/commands/cargo-bench.md
+++ b/src/doc/src/commands/cargo-bench.md
@@ -404,6 +404,18 @@ offline.
--frozen
Equivalent to specifying both --locked and --offline.
+
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
+
### Common Options
diff --git a/src/doc/src/commands/cargo-build.md b/src/doc/src/commands/cargo-build.md
index d0be79bbd0f..a8fe5f58623 100644
--- a/src/doc/src/commands/cargo-build.md
+++ b/src/doc/src/commands/cargo-build.md
@@ -335,6 +335,18 @@ offline.
--frozen
Equivalent to specifying both --locked and --offline.
+
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
+
### Common Options
diff --git a/src/doc/src/commands/cargo-check.md b/src/doc/src/commands/cargo-check.md
index 2db53d9dcd4..41fa6b73131 100644
--- a/src/doc/src/commands/cargo-check.md
+++ b/src/doc/src/commands/cargo-check.md
@@ -317,6 +317,18 @@ offline.
--frozen
Equivalent to specifying both --locked and --offline.
+
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
+
### Common Options
diff --git a/src/doc/src/commands/cargo-clean.md b/src/doc/src/commands/cargo-clean.md
index aa4e0eb46e3..72ae58c9577 100644
--- a/src/doc/src/commands/cargo-clean.md
+++ b/src/doc/src/commands/cargo-clean.md
@@ -138,6 +138,18 @@ offline.
--frozen
Equivalent to specifying both --locked and --offline.
+
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
+
### Common Options
diff --git a/src/doc/src/commands/cargo-doc.md b/src/doc/src/commands/cargo-doc.md
index a57389e8a2b..041c171975b 100644
--- a/src/doc/src/commands/cargo-doc.md
+++ b/src/doc/src/commands/cargo-doc.md
@@ -292,6 +292,18 @@ offline.
--frozen
Equivalent to specifying both --locked and --offline.
+
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
+
### Common Options
diff --git a/src/doc/src/commands/cargo-fetch.md b/src/doc/src/commands/cargo-fetch.md
index 694a4a2f0ca..782fdab355a 100644
--- a/src/doc/src/commands/cargo-fetch.md
+++ b/src/doc/src/commands/cargo-fetch.md
@@ -105,6 +105,18 @@ if there might be a newer version as indicated in the local copy of the index.
--frozen
Equivalent to specifying both --locked and --offline.
+
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
+
### Common Options
diff --git a/src/doc/src/commands/cargo-fix.md b/src/doc/src/commands/cargo-fix.md
index 6e3faa01b29..8937692393b 100644
--- a/src/doc/src/commands/cargo-fix.md
+++ b/src/doc/src/commands/cargo-fix.md
@@ -397,6 +397,18 @@ offline.
--frozen
Equivalent to specifying both --locked and --offline.
+
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
+
### Common Options
diff --git a/src/doc/src/commands/cargo-generate-lockfile.md b/src/doc/src/commands/cargo-generate-lockfile.md
index a87e86a6295..a361cabf02b 100644
--- a/src/doc/src/commands/cargo-generate-lockfile.md
+++ b/src/doc/src/commands/cargo-generate-lockfile.md
@@ -90,6 +90,18 @@ offline.
--frozen
Equivalent to specifying both --locked and --offline.
+
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
+
### Common Options
diff --git a/src/doc/src/commands/cargo-metadata.md b/src/doc/src/commands/cargo-metadata.md
index 3326c44a1ef..4d09d6c3df1 100644
--- a/src/doc/src/commands/cargo-metadata.md
+++ b/src/doc/src/commands/cargo-metadata.md
@@ -458,6 +458,18 @@ offline.
--frozen
Equivalent to specifying both --locked and --offline.
+
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
+
### Common Options
diff --git a/src/doc/src/commands/cargo-package.md b/src/doc/src/commands/cargo-package.md
index 765281f479c..c8a13f8eb23 100644
--- a/src/doc/src/commands/cargo-package.md
+++ b/src/doc/src/commands/cargo-package.md
@@ -233,6 +233,18 @@ offline.
Equivalent to specifying both --locked and --offline.
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
Equivalent to specifying both --locked and --offline.
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
Equivalent to specifying both --locked and --offline.
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
Equivalent to specifying both --locked and --offline.
+
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
Equivalent to specifying both --locked and --offline.
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
Equivalent to specifying both --locked and --offline.
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
Equivalent to specifying both --locked and --offline.
+
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
+
### Common Options
diff --git a/src/doc/src/commands/cargo-test.md b/src/doc/src/commands/cargo-test.md
index 0ea9255f9ce..3e3304948b3 100644
--- a/src/doc/src/commands/cargo-test.md
+++ b/src/doc/src/commands/cargo-test.md
@@ -434,6 +434,18 @@ offline.
Equivalent to specifying both --locked and --offline.
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
Equivalent to specifying both --locked and --offline.
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
Equivalent to specifying both --locked and --offline.
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
Equivalent to specifying both --locked and --offline.
+
--lockfile-pathPATH
+
Changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end with
+Cargo.lock (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing
+--lockfile-path will ignore existing lockfile at the default path, and instead will
+either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesn’t exist.
+This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH.
+
This option is only available on the nightly
+channel and
+requires the -Z unstable-options flag to enable (see
+#5707).
+
+
### Display Options
diff --git a/src/etc/man/cargo-add.1 b/src/etc/man/cargo-add.1
index ed8859da37f..d5db51f1547 100644
--- a/src/etc/man/cargo-add.1
+++ b/src/etc/man/cargo-add.1
@@ -254,6 +254,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-bench.1 b/src/etc/man/cargo-bench.1
index a9c3ba00387..df71be5174f 100644
--- a/src/etc/man/cargo-bench.1
+++ b/src/etc/man/cargo-bench.1
@@ -454,6 +454,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-build.1 b/src/etc/man/cargo-build.1
index 23e49a15e16..0eaa6085a71 100644
--- a/src/etc/man/cargo-build.1
+++ b/src/etc/man/cargo-build.1
@@ -372,6 +372,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-check.1 b/src/etc/man/cargo-check.1
index 50dd9e37f09..9d595bac4ce 100644
--- a/src/etc/man/cargo-check.1
+++ b/src/etc/man/cargo-check.1
@@ -353,6 +353,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-clean.1 b/src/etc/man/cargo-clean.1
index 00f47ad91f5..63fa9a4ecc2 100644
--- a/src/etc/man/cargo-clean.1
+++ b/src/etc/man/cargo-clean.1
@@ -153,6 +153,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-doc.1 b/src/etc/man/cargo-doc.1
index 789a736f27b..89bc9f661b7 100644
--- a/src/etc/man/cargo-doc.1
+++ b/src/etc/man/cargo-doc.1
@@ -320,6 +320,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-fetch.1 b/src/etc/man/cargo-fetch.1
index 6687506f46a..403b2195db4 100644
--- a/src/etc/man/cargo-fetch.1
+++ b/src/etc/man/cargo-fetch.1
@@ -119,6 +119,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-fix.1 b/src/etc/man/cargo-fix.1
index 0b94291bb3e..61ac3186343 100644
--- a/src/etc/man/cargo-fix.1
+++ b/src/etc/man/cargo-fix.1
@@ -448,6 +448,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-generate-lockfile.1 b/src/etc/man/cargo-generate-lockfile.1
index 732c805a73d..3a9f2bdf1a2 100644
--- a/src/etc/man/cargo-generate-lockfile.1
+++ b/src/etc/man/cargo-generate-lockfile.1
@@ -105,6 +105,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-metadata.1 b/src/etc/man/cargo-metadata.1
index 1357ad1f5d1..e2269935d59 100644
--- a/src/etc/man/cargo-metadata.1
+++ b/src/etc/man/cargo-metadata.1
@@ -476,6 +476,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-package.1 b/src/etc/man/cargo-package.1
index 8530e5454ca..1ac506c08fa 100644
--- a/src/etc/man/cargo-package.1
+++ b/src/etc/man/cargo-package.1
@@ -260,6 +260,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Miscellaneous Options"
.sp
\fB\-j\fR \fIN\fR,
diff --git a/src/etc/man/cargo-pkgid.1 b/src/etc/man/cargo-pkgid.1
index f8b7724bd58..6d6da78e35d 100644
--- a/src/etc/man/cargo-pkgid.1
+++ b/src/etc/man/cargo-pkgid.1
@@ -159,6 +159,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-publish.1 b/src/etc/man/cargo-publish.1
index 8a65416f7dd..0fd1c9e864e 100644
--- a/src/etc/man/cargo-publish.1
+++ b/src/etc/man/cargo-publish.1
@@ -192,6 +192,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Miscellaneous Options"
.sp
\fB\-j\fR \fIN\fR,
diff --git a/src/etc/man/cargo-remove.1 b/src/etc/man/cargo-remove.1
index 12f1dcfe808..1b90e2abb2d 100644
--- a/src/etc/man/cargo-remove.1
+++ b/src/etc/man/cargo-remove.1
@@ -119,6 +119,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Package Selection"
.sp
\fB\-p\fR \fIspec\fR\[u2026],
diff --git a/src/etc/man/cargo-run.1 b/src/etc/man/cargo-run.1
index 654322fb971..3794fe15928 100644
--- a/src/etc/man/cargo-run.1
+++ b/src/etc/man/cargo-run.1
@@ -257,6 +257,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-rustc.1 b/src/etc/man/cargo-rustc.1
index cd07c6a32d9..f5f18568375 100644
--- a/src/etc/man/cargo-rustc.1
+++ b/src/etc/man/cargo-rustc.1
@@ -371,6 +371,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-rustdoc.1 b/src/etc/man/cargo-rustdoc.1
index f89a6f7de82..b6393f8bb24 100644
--- a/src/etc/man/cargo-rustdoc.1
+++ b/src/etc/man/cargo-rustdoc.1
@@ -339,6 +339,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-test.1 b/src/etc/man/cargo-test.1
index 84b7ef1927e..945d90fb29b 100644
--- a/src/etc/man/cargo-test.1
+++ b/src/etc/man/cargo-test.1
@@ -481,6 +481,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-tree.1 b/src/etc/man/cargo-tree.1
index 9c08491c8b9..365ad15eb59 100644
--- a/src/etc/man/cargo-tree.1
+++ b/src/etc/man/cargo-tree.1
@@ -304,6 +304,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Feature Selection"
The feature flags allow you to control which features are enabled. When no
feature options are given, the \fBdefault\fR feature is activated for every
diff --git a/src/etc/man/cargo-update.1 b/src/etc/man/cargo-update.1
index c682e05fc40..cf20758fc20 100644
--- a/src/etc/man/cargo-update.1
+++ b/src/etc/man/cargo-update.1
@@ -181,6 +181,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Common Options"
.sp
\fB+\fR\fItoolchain\fR
diff --git a/src/etc/man/cargo-vendor.1 b/src/etc/man/cargo-vendor.1
index eae728deaf7..af7369f13d7 100644
--- a/src/etc/man/cargo-vendor.1
+++ b/src/etc/man/cargo-vendor.1
@@ -100,6 +100,20 @@ May also be specified with the \fBnet.offline\fR \fIconfig value\fR /Cargo.lock\fR) to \fIPATH\fR\&. \fIPATH\fR must end with
+\fBCargo.lock\fR (e.g. \fB\-\-lockfile\-path /tmp/temporary\-lockfile/Cargo.lock\fR). Note that providing
+\fB\-\-lockfile\-path\fR will ignore existing lockfile at the default path, and instead will
+either use the lockfile from \fIPATH\fR, or write a new lockfile into the provided \fIPATH\fR if it doesn\[cq]t exist.
+This flag can be used to run most commands in read\-only directories, writing lockfile into the provided \fIPATH\fR\&.
+.sp
+This option is only available on the \fInightly
+channel\fR and
+requires the \fB\-Z unstable\-options\fR flag to enable (see
+\fI#5707\fR ).
+.RE
.SS "Display Options"
.sp
\fB\-v\fR,
diff --git a/tests/testsuite/cargo_add/help/stdout.term.svg b/tests/testsuite/cargo_add/help/stdout.term.svg
index 2e1cacd322a..9335d606113 100644
--- a/tests/testsuite/cargo_add/help/stdout.term.svg
+++ b/tests/testsuite/cargo_add/help/stdout.term.svg
@@ -1,4 +1,4 @@
-