mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
Auto merge of #8681 - weihanglo:fix/redundant-messsage-local-crate-install, r=ehuss
Sweep unrelated message from unnecessary workspace infromation Resolves #8619 Only pass workspace information when the source is from a local crate installation.
This commit is contained in:
commit
f110fd9fc1
@ -81,17 +81,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
||||
config.reload_rooted_at(config.home().clone().into_path_unlocked())?;
|
||||
}
|
||||
|
||||
let workspace = args.workspace(config).ok();
|
||||
let mut compile_opts = args.compile_options(
|
||||
config,
|
||||
CompileMode::Build,
|
||||
workspace.as_ref(),
|
||||
ProfileChecking::Checked,
|
||||
)?;
|
||||
|
||||
compile_opts.build_config.requested_profile =
|
||||
args.get_profile_name(config, "release", ProfileChecking::Checked)?;
|
||||
|
||||
let krates = args
|
||||
.values_of("crate")
|
||||
.unwrap_or_default()
|
||||
@ -127,6 +116,26 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
||||
let version = args.value_of("version");
|
||||
let root = args.value_of("root");
|
||||
|
||||
// We only provide worksapce information for local crate installation from
|
||||
// one of the following sources:
|
||||
// - From current working directory (only work for edition 2015).
|
||||
// - From a specific local file path.
|
||||
let workspace = if from_cwd || args.is_present("path") {
|
||||
args.workspace(config).ok()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let mut compile_opts = args.compile_options(
|
||||
config,
|
||||
CompileMode::Build,
|
||||
workspace.as_ref(),
|
||||
ProfileChecking::Checked,
|
||||
)?;
|
||||
|
||||
compile_opts.build_config.requested_profile =
|
||||
args.get_profile_name(config, "release", ProfileChecking::Checked)?;
|
||||
|
||||
if args.is_present("list") {
|
||||
ops::install_list(root, config)?;
|
||||
} else {
|
||||
|
@ -1587,3 +1587,68 @@ fn install_yanked_cargo_package() {
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn install_cargo_package_in_a_patched_workspace() {
|
||||
pkg("foo", "0.1.0");
|
||||
pkg("fizz", "1.0.0");
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "bar"
|
||||
version = "0.1.0"
|
||||
authors = []
|
||||
|
||||
[workspace]
|
||||
members = ["baz"]
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
.file(
|
||||
"baz/Cargo.toml",
|
||||
r#"
|
||||
[package]
|
||||
name = "baz"
|
||||
version = "0.1.0"
|
||||
authors = []
|
||||
|
||||
[dependencies]
|
||||
fizz = "1"
|
||||
|
||||
[patch.crates-io]
|
||||
fizz = { version = "=1.0.0" }
|
||||
"#,
|
||||
)
|
||||
.file("baz/src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
let stderr = "\
|
||||
[WARNING] patch for the non root package will be ignored, specify patch at the workspace root:
|
||||
package: [..]/foo/baz/Cargo.toml
|
||||
workspace: [..]/foo/Cargo.toml
|
||||
";
|
||||
p.cargo("check").with_stderr_contains(&stderr).run();
|
||||
|
||||
// A crate installation must not emit any message from a workspace under
|
||||
// current working directory.
|
||||
// See https://github.com/rust-lang/cargo/issues/8619
|
||||
p.cargo("install foo")
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] `[..]` index
|
||||
[DOWNLOADING] crates ...
|
||||
[DOWNLOADED] foo v0.1.0 (registry [..])
|
||||
[INSTALLING] foo v0.1.0
|
||||
[COMPILING] foo v0.1.0
|
||||
[FINISHED] release [optimized] target(s) in [..]
|
||||
[INSTALLING] [..]foo[EXE]
|
||||
[INSTALLED] package `foo v0.1.0` (executable `foo[EXE]`)
|
||||
[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries
|
||||
",
|
||||
)
|
||||
.run();
|
||||
assert_has_installed_exe(cargo_home(), "foo");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user