mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +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 {
|
||||
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 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<()> {
|
||||
let home = self.home_path.clone().into_path_unlocked();
|
||||
let values = self.load_values_from(&home)?;
|
||||
pub fn reload_rooted_at<P: AsRef<Path>>(&mut self, path: P) -> CargoResult<()> {
|
||||
let values = self.load_values_from(path.as_ref())?;
|
||||
self.values.replace(values);
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1358,3 +1358,21 @@ fn install_global_cargo_config() {
|
||||
.with_stderr_contains("[..]--target nonexistent[..]")
|
||||
.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