Skip to content

Commit e5318c2

Browse files
committed
Fix clobbering of process vs component vs forc (#654)
1 parent 24064ac commit e5318c2

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/proxy_cli.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,34 @@ fn direct_proxy(proc_name: &str, args: &[OsString], toolchain: &Toolchain) -> Re
4646
// Install the entire toolchain declared in [toolchain] if it does not exist.
4747
toolchain.install_if_nonexistent(&description)?;
4848

49-
// Plugins distributed by forc have to be handled a little differently,
50-
// if one of them is called we want to check for 'forc' instead.
51-
let component_name = if Component::is_distributed_by_forc(proc_name) {
52-
component::FORC
53-
} else {
54-
proc_name
55-
};
49+
// If a specific version is declared, we want to call it from the
50+
// store and not from the toolchain directory.
51+
if let Some(version) = to.get_component_version(proc_name) {
52+
let component = match Component::resolve_from_name(proc_name) {
53+
Some(component) => component,
54+
None => {
55+
return Err(Error::new(
56+
ErrorKind::NotFound,
57+
format!("Component '{proc_name}' with version '{version}' not found"),
58+
)
59+
.into());
60+
}
61+
};
5662

57-
// If a specific version is declared, we want to call it from the store and not from the toolchain directory.
58-
if let Some(version) = to.get_component_version(component_name) {
5963
let store = Store::from_env()?;
6064

61-
if !store.has_component(component_name, version) {
65+
if !store.has_component(&component.name, version) {
6266
let download_cfg = DownloadCfg::new(
63-
component_name,
64-
TargetTriple::from_component(component_name)?,
67+
&component.name,
68+
TargetTriple::from_component(&component.name)?,
6569
Some(version.clone()),
6670
)?;
67-
// Install components within [components] that are declared but missing from the store.
6871
store.install_component(&download_cfg)?;
69-
};
72+
}
7073

7174
(
7275
store
73-
.component_dir_path(component_name, version)
76+
.component_dir_path(&component.name, version)
7477
.join(proc_name),
7578
description.to_string(),
7679
)
@@ -94,7 +97,7 @@ fn direct_proxy(proc_name: &str, args: &[OsString], toolchain: &Toolchain) -> Re
9497
ErrorKind::NotFound => Err(Error::new(
9598
ErrorKind::NotFound,
9699
format!(
97-
"component '{proc_name}' not found in currently active toolchain '{toolchain_name}'"
100+
"Component '{proc_name}' not found in currently active toolchain '{toolchain_name}'"
98101
),
99102
)),
100103
_ => Err(error),

0 commit comments

Comments
 (0)