Skip to content

Commit 1354647

Browse files
committed
feat: lockfile path implies --locked on cargo install
1 parent 32f024f commit 1354647

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/cargo/core/workspace.rs

+4
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,10 @@ impl<'gctx> Workspace<'gctx> {
662662
self.requested_lockfile_path = path;
663663
}
664664

665+
pub fn get_requested_lockfile_path(&mut self) -> Option<&PathBuf> {
666+
self.requested_lockfile_path.as_ref()
667+
}
668+
665669
/// Get the lowest-common denominator `package.rust-version` within the workspace, if specified
666670
/// anywhere
667671
pub fn rust_version(&self) -> Option<&RustVersion> {

src/cargo/ops/cargo_install.rs

+4
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,10 @@ fn make_ws_rustc_target<'gctx>(
825825
ws
826826
};
827827
ws.set_ignore_lock(gctx.lock_update_allowed());
828+
// if --lockfile-path is set, imply --locked
829+
if ws.get_requested_lockfile_path().is_some() {
830+
ws.set_ignore_lock(false);
831+
}
828832
ws.set_require_optional_deps(false);
829833

830834
let rustc = gctx.load_global_rustc(Some(&ws))?;

0 commit comments

Comments
 (0)