mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Allow cargo install --path P
to load config from P.
This commit is contained in:
parent
ede459e251
commit
fe8f29432d
@ -78,7 +78,11 @@ continuous integration systems.",
|
|||||||
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
|
||||||
let registry = args.registry(config)?;
|
let registry = args.registry(config)?;
|
||||||
|
|
||||||
config.reload_rooted_at_cargo_home()?;
|
if let Some(path) = args.value_of_path("path", config) {
|
||||||
|
config.reload_rooted_at(path)?;
|
||||||
|
} else {
|
||||||
|
config.reload_rooted_at(config.home().clone().into_path_unlocked())?;
|
||||||
|
}
|
||||||
|
|
||||||
let workspace = args.workspace(config).ok();
|
let workspace = args.workspace(config).ok();
|
||||||
let mut compile_opts = args.compile_options(config, CompileMode::Build, workspace.as_ref())?;
|
let mut compile_opts = args.compile_options(config, CompileMode::Build, workspace.as_ref())?;
|
||||||
|
@ -285,9 +285,8 @@ impl Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reload_rooted_at_cargo_home(&mut self) -> CargoResult<()> {
|
pub fn reload_rooted_at<P: AsRef<Path>>(&mut self, path: P) -> CargoResult<()> {
|
||||||
let home = self.home_path.clone().into_path_unlocked();
|
let values = self.load_values_from(path.as_ref())?;
|
||||||
let values = self.load_values_from(&home)?;
|
|
||||||
self.values.replace(values);
|
self.values.replace(values);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1358,3 +1358,21 @@ fn install_global_cargo_config() {
|
|||||||
.with_stderr_contains("[..]--target nonexistent[..]")
|
.with_stderr_contains("[..]--target nonexistent[..]")
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn install_path_config() {
|
||||||
|
project()
|
||||||
|
.file(
|
||||||
|
".cargo/config",
|
||||||
|
r#"
|
||||||
|
[build]
|
||||||
|
target = 'nonexistent'
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/main.rs", "fn main() {}")
|
||||||
|
.build();
|
||||||
|
cargo_process("install --path foo")
|
||||||
|
.with_status(101)
|
||||||
|
.with_stderr_contains("[..]--target nonexistent[..]")
|
||||||
|
.run();
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user