Skip to content

Commit

Permalink
fix: sometimes lockfiles can't be found
Browse files Browse the repository at this point in the history
Lockfiles are weird. The behavior is to generate the lockfile at the parent
dir of the `--manifest-path` parameter of `cargo vendor`, and NOT where
`cargo vendor` was invoked. If it is a subcrate that is part of a workspace,
the lockfile is regenerated from where the workspace manifest is.

For now we do a simple logic to get the lockfile path.  In the future,
a big maybe, we will check if a sub project's manifest file is part of a
workspace so in that way, we can determine where the lockfile is

Signed-off-by: Soc Virnyl Estela <[email protected]>
  • Loading branch information
uncomfyhalomacro committed Nov 17, 2023
1 parent 2a340de commit 8b9ef3f
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions cargo/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,28 @@ pub fn process_src(args: &Opts, prjdir: &Path) -> Result<(), OBSCargoError> {

// Setup some common paths we'll use from here out.
let outdir = args.outdir.to_owned();
let cargo_lock = prjdir.join("Cargo.lock");
// let cargo_config = prjdir.join("cargo_config");
let first_manifest_parent_path = first_manifest.parent();

// Lockfiles are weird. The behavior is to generate
// the lockfile at the parent dir of the `--manifest-path`
// parameter of `cargo vendor`, and NOT where `cargo vendor`
// was invoked. If it is a subcrate that is part of a workspace,
// the lockfile is regenerated from where the workspace
// manifest is.
// WARN For now we do a simple logic to get the lockfile path.
// TODO Check if a manifest file is part of a workspace
// so in that way, we can determine where the lockfile is
let cargo_lock = match first_manifest_parent_path {
Some(custom_path) => {
let lockfilepath = custom_path.join("Cargo.lock");
if lockfilepath.exists() {
lockfilepath
} else {
prjdir.join("Cargo.lock")
}
}
None => prjdir.join("Cargo.lock"),
};
let cargo_config = prjdir.join(".cargo/config");
let vendor_dir = prjdir.join("vendor");
let update = args.update;
Expand Down

0 comments on commit 8b9ef3f

Please sign in to comment.