Skip to main content

isothrum_machine/
install.rs

1//! Installing and removing the tools a computer runs projects with: the container engine, Vagrant,
2//! Terraform, the hypervisors, the cloud CLIs and the services they need. Each tool's row
3//! ([`Dependency::row`]) says where it exists and what proves it installed; its install and its
4//! removal are one exhaustive match per OS over the tool and the package manager, so a tool, an OS
5//! or a package manager added is a compile error until each says what it does there. Every plan is
6//! built on any OS, so the tests read every row.
7//!
8//! A plan is a list of [`Step`]s, each one program, run in order through the [`Context`]'s runner
9//! ([`run_steps`]): the OS's own trusted flows, never a password prompt of the caller's (pkexec's
10//! on Linux, or `sudo -n` when nobody is there to answer one: [`Elevation`]). Why a plan can't be
11//! made ([`Refusal`]) and why a step failed ([`StepFailed`]) are codes a UI says in its own words.
12//! What an install added, read before and after its plan runs, is [`added`]'s; what it leaves on
13//! record, so a clean-up removes only what it added, [`record`]'s; the removal of only that,
14//! [`removal`].
15
16use serde::{Deserialize, Serialize};
17
18use crate::context::Context;
19use crate::host::{ALL_OSES, Arch, HostOs};
20use crate::providers::{Provider, ProviderRow};
21
22pub mod added;
23pub mod brew;
24pub mod exit_codes;
25pub mod interaction;
26pub mod linux;
27pub(crate) mod mac_image;
28pub mod macos;
29mod pkexec;
30pub mod record;
31pub mod root;
32mod steps;
33mod vmware_utility;
34pub mod windows;
35
36pub use added::{Before, Installed, Item, before, items, there};
37pub use interaction::{BROADCOM_DOWNLOADS, Interaction, OVFTOOL_PAGE, Prompt, VMWARE_FUSION_PAGE, VMWARE_WORKSTATION_PAGE, VendorPage, interactions};
38pub use mac_image::set_app_name;
39pub use steps::{Agreement, NotServed, Note, Step, StepFailed, command_line, run_step, run_steps, step};
40
41/// A tool a setup installs.
42#[derive(Deserialize, Serialize, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
43#[cfg_attr(any(test, feature = "ts-rs"), derive(ts_rs::TS))]
44#[serde(rename_all = "lowercase")]
45pub enum Dependency {
46    /// Docker: Docker Desktop on macOS and Windows, Docker Engine on Linux.
47    Docker,
48    /// HashiCorp's Vagrant.
49    Vagrant,
50    /// HashiCorp's Terraform.
51    Terraform,
52    /// Oracle's VirtualBox.
53    Virtualbox,
54    /// QEMU.
55    Qemu,
56    /// UTM (macOS).
57    Utm,
58    /// libvirt, with what the vagrant-libvirt plugin builds against (Linux).
59    Libvirt,
60    /// The AWS CLI.
61    Awscli,
62    /// The Azure CLI.
63    Azurecli,
64    /// The Google Cloud CLI.
65    Gcloud,
66    /// Windows Subsystem for Linux (WSL 2), enabled through its own installer.
67    Wsl,
68    /// HashiCorp's Vagrant VMware Utility, the service VMware's Vagrant plugin drives VMware
69    /// through.
70    #[serde(rename = "vmware-utility")]
71    VmwareUtility,
72    /// Windows' Hyper-V feature, turned on through Windows' own servicing tool (DISM).
73    Hyperv,
74}
75
76/// Where a tool exists.
77#[derive(Debug, Clone, Copy, PartialEq, Eq)]
78pub enum Runs {
79    /// On these OSes.
80    On(&'static [HostOs]),
81    /// Where this hypervisor does ([`ProviderRow::of`]): the one table of which OS a hypervisor
82    /// belongs to.
83    As(Provider),
84}
85
86/// A program and the arguments it answers with its version.
87pub type Probe = (&'static str, &'static [&'static str]);
88
89/// A tool's row of the setup's table ([`Dependency::row`]).
90#[derive(Debug, Clone, Copy, PartialEq, Eq)]
91#[non_exhaustive]
92pub struct ToolRow {
93    /// Where it exists.
94    pub runs: Runs,
95    /// The command that proves it installed, when there is one worth trusting (`wsl.exe` ships
96    /// with Windows whether WSL is set up or not; UTM is an app; VMware's utility a service). A
97    /// hypervisor has none here: its provider's ([`crate::providers::hypervisor_probe`]) is the one
98    /// a setup and the provider's detection both read, so they never disagree.
99    pub probe: Option<Probe>,
100    /// The app bundle that proves it installed on macOS, also before its CLI is on `PATH`, once
101    /// whole ([`present`]). Looked for in [`crate::host::Devices::applications`], by its name.
102    pub mac_app: Option<&'static str>,
103    /// Its winget package, when winget installs and removes it on Windows.
104    pub winget: Option<&'static str>,
105    /// Where its user installs it themselves when the setup can't (a Linux distribution without
106    /// apt or dnf).
107    pub own_url: Option<&'static str>,
108    /// Where it runs, the CPUs its vendor ships no build for that a setup installs, each with the
109    /// vendor's reason: refused there ([`Refusal::NoBuild`]), never offered.
110    pub no_build: &'static [NoBuild],
111}
112
113/// An OS and CPU a tool's vendor ships no build for that a setup installs, and why.
114#[derive(Debug, Clone, Copy, PartialEq, Eq)]
115pub struct NoBuild {
116    /// The OS.
117    pub os: HostOs,
118    /// The CPU.
119    pub arch: Arch,
120    /// Why, as its vendor has it.
121    pub why: &'static str,
122}
123
124/// Google Cloud CLI on Windows on Arm: Google's Windows installer (the one winget runs) puts no
125/// Python on an Arm64 computer, and the CLI needs one, so its install stops ("you must have
126/// Python installed", the installer's exit code 2). Google lists no Windows Arm64 build.
127/// Vagrant on Linux arm64: HashiCorp ships no Linux arm64 build (its apt repository serves amd64
128/// only), so apt installs the distribution's own (Debian 13: 2.3.7), older than the 2.4.0 a run
129/// needs. Before 2.4.0 Vagrant reads no box's architecture: on an arm64 computer it adds a box's
130/// `x86_64` build (checked: Debian's 2.3.7 on arm64 fetched `cloud-image/debian-13`'s
131/// `libvirt/amd64` box), so every project's VM is of the wrong CPU, and Isothrum refuses it.
132const VAGRANT_NO_BUILD: &[NoBuild] = &[NoBuild {
133    os: HostOs::Linux,
134    arch: Arch::Arm64,
135    why: "HashiCorp ships no Linux arm64 build, and the distribution's Vagrant is older than the 2.4.0 a run needs (an older one adds a box's x86_64 build on an arm64 computer)",
136}];
137
138const GCLOUD_NO_BUILD: &[NoBuild] = &[NoBuild {
139    os: HostOs::Windows,
140    arch: Arch::Arm64,
141    why: "Google ships no Windows on Arm build: its installer brings no Python there, which the CLI needs",
142}];
143
144impl Dependency {
145    /// Every tool, in the setup's order.
146    pub const ALL: [Dependency; 13] = [
147        Dependency::Docker,
148        Dependency::Vagrant,
149        Dependency::Terraform,
150        Dependency::Virtualbox,
151        Dependency::Qemu,
152        Dependency::Utm,
153        Dependency::Libvirt,
154        Dependency::Awscli,
155        Dependency::Azurecli,
156        Dependency::Gcloud,
157        Dependency::Wsl,
158        Dependency::VmwareUtility,
159        Dependency::Hyperv,
160    ];
161
162    /// Its row of the setup's table.
163    #[must_use]
164    pub fn row(self) -> ToolRow {
165        const ANY: Runs = Runs::On(&ALL_OSES);
166        /// A row with no macOS app.
167        const fn row(runs: Runs, probe: Option<Probe>, winget: Option<&'static str>, own_url: Option<&'static str>) -> ToolRow {
168            ToolRow {
169                runs,
170                probe,
171                mac_app: None,
172                winget,
173                own_url,
174                no_build: &[],
175            }
176        }
177        match self {
178            Dependency::Docker => ToolRow {
179                mac_app: Some("/Applications/Docker.app"),
180                ..row(
181                    ANY,
182                    Some(("docker", &["--version"])),
183                    Some("Docker.DockerDesktop"),
184                    Some("https://docs.docker.com/engine/install/"),
185                )
186            },
187            Dependency::Vagrant => ToolRow {
188                no_build: VAGRANT_NO_BUILD,
189                ..row(
190                    ANY,
191                    Some(("vagrant", &["--version"])),
192                    Some("Hashicorp.Vagrant"),
193                    Some("https://developer.hashicorp.com/vagrant/install"),
194                )
195            },
196            Dependency::Terraform => row(ANY, Some(("terraform", &["version"])), Some("Hashicorp.Terraform"), None),
197            Dependency::Virtualbox => ToolRow {
198                mac_app: Some("/Applications/VirtualBox.app"),
199                ..row(
200                    Runs::As(Provider::Virtualbox),
201                    None,
202                    Some("Oracle.VirtualBox"),
203                    Some("https://www.virtualbox.org/wiki/Linux_Downloads"),
204                )
205            },
206            Dependency::Qemu => row(Runs::As(Provider::Qemu), None, None, Some("https://www.qemu.org/download/")),
207            Dependency::Utm => ToolRow {
208                mac_app: Some("/Applications/UTM.app"),
209                ..row(Runs::As(Provider::Utm), None, None, None)
210            },
211            Dependency::Libvirt => row(Runs::As(Provider::Libvirt), None, None, Some("https://libvirt.org/")),
212            Dependency::Awscli => row(ANY, Some(("aws", &["--version"])), Some("Amazon.AWSCLI"), None),
213            Dependency::Azurecli => row(ANY, Some(("az", &["version"])), Some("Microsoft.AzureCLI"), None),
214            Dependency::Gcloud => ToolRow {
215                no_build: GCLOUD_NO_BUILD,
216                ..row(ANY, Some(("gcloud", &["--version"])), Some("Google.CloudSDK"), None)
217            },
218            Dependency::Wsl => row(Runs::On(&[HostOs::Windows]), None, None, None),
219            Dependency::VmwareUtility => row(ANY, None, None, Some("https://developer.hashicorp.com/vagrant/install/vmware")),
220            Dependency::Hyperv => row(Runs::As(Provider::Hyperv), None, None, None),
221        }
222    }
223
224    /// The tool a setup installs as hypervisor `provider`, where it does (the row that names it).
225    #[must_use]
226    pub fn of_hypervisor(provider: Provider) -> Option<Dependency> {
227        Dependency::ALL.into_iter().find(|d| d.hypervisor() == Some(provider))
228    }
229
230    /// The hypervisor it serves without being it, when it does: VMware's utility serves VMware
231    /// Workstation (or Fusion), whose installer it needs first (Windows' MSI refuses to run
232    /// without it, exiting 1603; on Linux its service doesn't answer). A setup installs it once
233    /// that hypervisor is installed, never before ([`crate::requirements::Plan::After`]).
234    #[must_use]
235    pub fn serves(self) -> Option<Provider> {
236        match self {
237            Dependency::VmwareUtility => Some(Provider::VmwareDesktop),
238            _ => None,
239        }
240    }
241
242    /// The hypervisor it is, when it is one.
243    #[must_use]
244    pub fn hypervisor(self) -> Option<Provider> {
245        match self.row().runs {
246            Runs::As(provider) => Some(provider),
247            Runs::On(_) => None,
248        }
249    }
250
251    /// Why its vendor ships no build of it for `os` on `arch` that a setup installs, when it
252    /// doesn't ([`ToolRow::no_build`]).
253    #[must_use]
254    pub fn no_build(self, os: HostOs, arch: Arch) -> Option<&'static str> {
255        self.row().no_build.iter().find(|n| n.os == os && n.arch == arch).map(|n| n.why)
256    }
257
258    /// Whether it exists on `os`: a hypervisor where its provider's row says, the rest by its own
259    /// row. An install or a removal elsewhere is refused ([`Refusal::NotHere`]).
260    #[must_use]
261    pub fn runs_on(self, os: HostOs) -> bool {
262        match self.row().runs {
263            Runs::On(oses) => oses.contains(&os),
264            Runs::As(provider) => ProviderRow::of(provider).oses.contains(&os),
265        }
266    }
267
268    /// [`Dependency::runs_on`] as an install or a removal asks it: refused when it doesn't.
269    pub(crate) fn runs_here(self, os: HostOs) -> Result<(), Refusal> {
270        if self.runs_on(os) {
271            Ok(())
272        } else {
273            Err(Refusal::NotHere { dependency: self, os })
274        }
275    }
276}
277
278/// The step that installs the Vagrant plugin `plugin` (for this account, no administrator), when
279/// `plugin` names one: only ever a `vagrant-*` / `vagrant_*` identifier, never an option or a path.
280#[must_use]
281pub fn vagrant_plugin(plugin: &str) -> Option<Step> {
282    let named = (plugin.starts_with("vagrant-") || plugin.starts_with("vagrant_"))
283        && plugin.len() <= 64
284        && plugin.chars().all(|c| c.is_ascii_alphanumeric() || c == '-' || c == '_');
285    named.then(|| step("vagrant", &["plugin", "install", plugin]))
286}
287
288/// How a step that needs an administrator is elevated. With someone there to answer, the OS's
289/// password prompt (pkexec's on Linux, macOS's own); with nobody (a script, a machine set up
290/// unattended), no prompt may be raised: as is when the process is root already, else through
291/// `sudo -n`, refused at once rather than waiting on a password.
292#[derive(Debug, Clone, Copy, PartialEq, Eq)]
293pub enum Elevation {
294    /// The OS's password prompt: pkexec's (Linux), macOS's administrator prompt.
295    Prompt,
296    /// Unattended, `root` when the process is root already.
297    Unattended {
298        /// Whether the process runs as root.
299        root: bool,
300    },
301}
302
303/// Why no administrator's step can run here: nobody can be asked, and nothing runs one without
304/// asking ([`Elevation::here`]).
305#[derive(Debug, Clone, Copy, PartialEq, Eq)]
306#[non_exhaustive]
307pub enum NoElevation {
308    /// Not root, `sudo` asks for a password, and no login session can show the OS's password
309    /// prompt (an ssh session, a Linux machine without a desktop).
310    NoPromptNorSudo,
311}
312
313impl std::fmt::Display for NoElevation {
314    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
315        match self {
316            NoElevation::NoPromptNorSudo => f.write_str(
317                "no administrator's step can run: sudo asks for a password, and no login session here can show the password prompt (an ssh session can't)",
318            ),
319        }
320    }
321}
322
323impl std::error::Error for NoElevation {}
324
325/// What macOS's `launchctl managername` says in a login session at the Mac's screen, where its
326/// administrator prompt shows; an ssh session's is `Background`.
327const MAC_LOGIN_SESSION: &str = "Aqua";
328
329impl Elevation {
330    /// How a root step is elevated on the context's host when nobody chose: as is when root;
331    /// through `sudo -n` only when it runs a command without a password (`sudo -n true`); else
332    /// through the OS's password prompt where a login session can show it (macOS's administrator
333    /// prompt at the Mac's screen, `launchctl managername` saying `Aqua`; pkexec's on a Linux
334    /// desktop, `desktop` saying one is there); else refused. Windows always asks through UAC.
335    /// An app with someone at it asks through the prompt without this ([`Elevation::Prompt`]).
336    ///
337    /// # Errors
338    ///
339    /// [`NoElevation`]: why no root step can run here.
340    pub async fn here(cx: &Context, desktop: bool) -> Result<Elevation, NoElevation> {
341        if cx.host.os == HostOs::Windows {
342            return Ok(Elevation::Prompt);
343        }
344        if cx.read_ok("id", &["-u"]).await.is_ok_and(|uid| uid.trim() == "0") {
345            return Ok(Elevation::Unattended { root: true });
346        }
347        if cx.read_ok("sudo", &["-n", "true"]).await.is_ok() {
348            return Ok(Elevation::Unattended { root: false });
349        }
350        let session = match cx.host.os {
351            HostOs::Macos => cx.read_ok("launchctl", &["managername"]).await.is_ok_and(|m| m.trim() == MAC_LOGIN_SESSION),
352            _ => desktop,
353        };
354        if session { Ok(Elevation::Prompt) } else { Err(NoElevation::NoPromptNorSudo) }
355    }
356
357    /// `program` with `args`, run as root this way.
358    #[must_use]
359    pub fn as_root(self, program: &str, args: &[String]) -> (String, Vec<String>) {
360        let all = |prefix: &[&str]| {
361            prefix
362                .iter()
363                .map(ToString::to_string)
364                .chain(std::iter::once(program.to_owned()))
365                .chain(args.iter().cloned())
366                .collect()
367        };
368        match self {
369            Elevation::Prompt => ("pkexec".into(), all(&[])),
370            Elevation::Unattended { root: true } => (program.to_owned(), args.to_vec()),
371            Elevation::Unattended { root: false } => ("sudo".into(), all(&["-n"])),
372        }
373    }
374}
375
376/// Why a plan can't be made here. A UI says each in its own words.
377#[derive(Debug, Clone, PartialEq, Eq)]
378#[non_exhaustive]
379pub enum Refusal {
380    /// The tool doesn't run on this OS: there is nothing of it to install or remove here.
381    NotHere {
382        /// The tool.
383        dependency: Dependency,
384        /// The OS.
385        os: HostOs,
386    },
387    /// A Linux distribution with neither apt nor dnf: its user installs the tool themselves.
388    WithoutPackages {
389        /// The tool.
390        dependency: Dependency,
391    },
392    /// A tool installed through apt only for now, on a dnf distribution.
393    AptOnly {
394        /// The tool.
395        dependency: Dependency,
396    },
397    /// Homebrew isn't installed, which a macOS install goes through.
398    NoHomebrew,
399    /// Homebrew isn't installed, which this removal on macOS goes through.
400    HomebrewNeeded,
401    /// VirtualBox's removal on macOS without its installer image, whose uninstaller it runs
402    /// ([`macos::virtualbox_image`]).
403    NoVirtualboxImage,
404    /// A Windows feature, which its user turns off in Windows Features.
405    WindowsFeature {
406        /// The tool.
407        dependency: Dependency,
408    },
409    /// Windows on Arm, which this hypervisor (or the one this tool serves) isn't built for.
410    NotOnWindowsOnArm {
411        /// The tool.
412        dependency: Dependency,
413        /// The hypervisor.
414        provider: Provider,
415    },
416    /// Its vendor ships no build for this OS and CPU that a setup installs ([`ToolRow::no_build`]).
417    NoBuild {
418        /// The tool.
419        dependency: Dependency,
420        /// The OS.
421        os: HostOs,
422        /// The CPU.
423        arch: Arch,
424        /// Why, as its vendor has it.
425        why: &'static str,
426    },
427    /// The private file a root step's proxy settings go through couldn't be written: what the OS
428    /// said.
429    PrivateFile(String),
430    /// A removal of nothing an install added ([`removal`]): what was there before an install is
431    /// never removed.
432    NothingAdded {
433        /// The tool.
434        dependency: Dependency,
435    },
436}
437
438impl std::fmt::Display for Refusal {
439    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
440        match self {
441            Refusal::NotHere { dependency, os } => write!(f, "{dependency:?} doesn't run on {}", crate::host::os_name(*os)),
442            Refusal::WithoutPackages { dependency } => write!(f, "{dependency:?}: this distribution has neither apt nor dnf"),
443            Refusal::AptOnly { dependency } => write!(f, "{dependency:?} installs through apt only"),
444            Refusal::NoHomebrew | Refusal::HomebrewNeeded => f.write_str("Homebrew isn't installed"),
445            Refusal::WindowsFeature { dependency } => write!(f, "{dependency:?} is turned off in Windows Features"),
446            Refusal::NotOnWindowsOnArm { dependency, .. } => write!(f, "{dependency:?} doesn't run on Windows on Arm"),
447            Refusal::NoBuild { dependency, os, arch, why } => write!(f, "{dependency:?} isn't offered on {} {arch:?}: {why}", crate::host::os_name(*os)),
448            Refusal::NoVirtualboxImage => f.write_str("VirtualBox's installer image is needed to run its uninstaller"),
449            Refusal::PrivateFile(why) => write!(f, "a root step's private file couldn't be written: {why}"),
450            Refusal::NothingAdded { dependency } => write!(f, "nothing of {dependency:?} was added by an install, so nothing of it is removed"),
451        }
452    }
453}
454
455impl std::error::Error for Refusal {}
456
457/// The install of `dep` on `host`, whatever its OS: macOS's Homebrew formulae and vendors' disk
458/// images and packages (installed as an administrator `elevation`'s way), Windows' winget packages
459/// and elevated installers, or Linux's root script for the user `user` (joined to the groups a
460/// tool's devices need), its root steps run `elevation`'s way with this process's proxy
461/// ([`linux::proxy_assignments`]). The one call a caller plans an
462/// install with: which OS's plan applies is the host's, never the OS the crate is built for.
463///
464/// # Errors
465///
466/// [`Refusal`]: why it can't be installed there ([`Refusal::NotHere`] first, before the package
467/// manager is looked at).
468///
469/// What it asks of its user ([`interactions`]) is the plan's last step's, the one that installs
470/// the tool (one before it only prepares: a Homebrew tap trusted).
471pub fn plan(dep: Dependency, host: &crate::host::Host, user: Option<&str>, elevation: Elevation) -> Result<Vec<Step>, Refusal> {
472    let mut steps = os_plan(dep, host, user, elevation)?;
473    if let Some(last) = steps.last_mut() {
474        last.interactions = interactions(dep, host, elevation, user);
475    }
476    Ok(steps)
477}
478
479/// [`plan`]'s steps, as the host's OS makes them.
480fn os_plan(dep: Dependency, host: &crate::host::Host, user: Option<&str>, elevation: Elevation) -> Result<Vec<Step>, Refusal> {
481    dep.runs_here(host.os)?;
482    match host.os {
483        HostOs::Macos => macos::install(dep, host.packages, host.arch, elevation),
484        HostOs::Windows => windows::install(dep, host.arch),
485        HostOs::Linux => {
486            let root = linux::Root::with_this_proxy(elevation);
487            linux::install(dep, host.packages, host.arch, user, &root)
488        }
489    }
490}
491
492/// The removal of what `added` lists of `dep` on `host` ([`Installed::added`], as on record),
493/// and of nothing else: on Linux those of its packages ([`added::packages`]), through the package
494/// manager that installed them, its root steps run `elevation`'s way with this process's proxy;
495/// elsewhere, and for the AWS CLI's folder, the tool itself when the record says the install
496/// added it ([`Item::Tool`]). On macOS, VirtualBox's uninstaller runs from its installer image
497/// (`virtualbox`).
498///
499/// # Errors
500///
501/// [`Refusal::NothingAdded`] when `added` lists nothing of `dep`'s, or why it can't be removed
502/// there.
503pub fn removal(dep: Dependency, host: &crate::host::Host, added: &[Item], elevation: Elevation, virtualbox: Option<&str>) -> Result<Vec<Step>, Refusal> {
504    dep.runs_here(host.os)?;
505    match host.os {
506        HostOs::Linux => {
507            let root = linux::Root::with_this_proxy(elevation);
508            linux::uninstall(dep, host.packages, added, &root)
509        }
510        _ if !added.contains(&Item::Tool(dep)) => Err(Refusal::NothingAdded { dependency: dep }),
511        HostOs::Macos => macos::uninstall(dep, host.packages, virtualbox),
512        HostOs::Windows => windows::uninstall(dep),
513    }
514}
515
516/// Whether `dep` is installed on the context's host; `None` when that can't be told (WSL, Hyper-V).
517/// The tool itself (`tool_found`); a hypervisor with the programs its VMs need beside it
518/// ([`crate::providers::helpers()`]), as its provider's detection reads it: one without them is
519/// installed again, which brings them.
520pub async fn present(cx: &Context, dep: Dependency) -> Option<bool> {
521    let found = tool_found(cx, dep).await?;
522    match dep.hypervisor() {
523        Some(provider) if found => Some(crate::providers::helper::missing(cx, provider).await.is_none()),
524        _ => Some(found),
525    }
526}
527
528/// Whether `dep` itself is on the context's host, its helpers aside; `None` when that can't be
529/// told (WSL, Hyper-V). Its macOS app bundle, once whole (no copy under way, its signature
530/// verifying: one that isn't is installed again), else its version probe ([`ToolRow::probe`]; a
531/// hypervisor's, its provider's); VMware's utility, a service, as
532/// [`crate::providers::vmware_utility`] finds it.
533pub(crate) async fn tool_found(cx: &Context, dep: Dependency) -> Option<bool> {
534    if dep == Dependency::VmwareUtility {
535        return Some(crate::providers::vmware_utility(&cx.host).await != crate::providers::UtilityState::Missing);
536    }
537    let row = dep.row();
538    let mac_app = row.mac_app.filter(|_| cx.host.os == HostOs::Macos);
539    if let Some(app) = mac_app
540        .and_then(|a| std::path::Path::new(a).file_name())
541        .map(|a| cx.host.devices.applications.join(a))
542        && app.exists()
543    {
544        return Some(mac_image::complete(cx, &app).await);
545    }
546    let probe = dep
547        .hypervisor()
548        .map_or(row.probe, |provider| crate::providers::hypervisor_probe(provider, cx.host.arch));
549    match probe {
550        Some((program, args)) => Some(cx.read_ok(program, args).await.is_ok()),
551        None if mac_app.is_some() => Some(false),
552        None => None,
553    }
554}
555
556#[cfg(test)]
557mod tests;