Skip to content

Commit

Permalink
feat: lockfile path implies --locked on cargo install
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifropc committed Sep 17, 2024
1 parent 32f024f commit 1354647
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cargo/core/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ impl<'gctx> Workspace<'gctx> {
self.requested_lockfile_path = path;
}

pub fn get_requested_lockfile_path(&mut self) -> Option<&PathBuf> {
self.requested_lockfile_path.as_ref()
}

/// Get the lowest-common denominator `package.rust-version` within the workspace, if specified
/// anywhere
pub fn rust_version(&self) -> Option<&RustVersion> {
Expand Down
4 changes: 4 additions & 0 deletions src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,10 @@ fn make_ws_rustc_target<'gctx>(
ws
};
ws.set_ignore_lock(gctx.lock_update_allowed());
// if --lockfile-path is set, imply --locked
if ws.get_requested_lockfile_path().is_some() {
ws.set_ignore_lock(false);
}
ws.set_require_optional_deps(false);

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

0 comments on commit 1354647

Please sign in to comment.