Skip to content

Commit

Permalink
fix: create ephemeral workspace for git source
Browse files Browse the repository at this point in the history
  • Loading branch information
Rustin170506 committed Apr 13, 2024
1 parent db02d39 commit beeac46
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/cargo/core/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ impl<'gctx> Workspace<'gctx> {
ws.member_ids.insert(id);
ws.default_members.push(ws.current_manifest.clone());
ws.set_resolve_behavior();
// The find_root function is used here to traverse the directory tree and locate the root of the workspace.
// Despite being ephemeral, we still need to validate all the manifests in the workspace,
// which is what `find_root` helps us achieve here.
ws.find_root(ws.current_manifest.clone().as_path())?;
Ok(ws)
}

Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ fn make_ws_rustc_target<'gctx>(
source_id: &SourceId,
pkg: Package,
) -> CargoResult<(Workspace<'gctx>, Rustc, String)> {
let mut ws = if source_id.is_git() || source_id.is_path() {
let mut ws = if source_id.is_path() {
Workspace::new(pkg.manifest_path(), gctx)?
} else {
Workspace::ephemeral(pkg, gctx, None, false)?
Expand Down
1 change: 1 addition & 0 deletions tests/testsuite/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2124,6 +2124,7 @@ fn git_install_the_same_bin_twice_with_different_rev() {
"\
[UPDATING] git repository [..]
[INSTALLING] bin1 v0.1.0 [..]
[COMPILING] bin1 v0.1.0 [..]
[FINISHED] [..]
[REPLACING] [..]home/.cargo/bin/bin1[..]
[REPLACED] package `bin1 [..]
Expand Down

0 comments on commit beeac46

Please sign in to comment.