pxcli_unlocked/toolchain.rs
1use crate::locator::PavexLocator;
2use crate::pavexc::get_or_install_from_version;
3use crate::state::State;
4use cargo_like_utils::shell::Shell;
5use std::path::PathBuf;
6
7/// Retrieve the path to the default `pavexc` binary, according to the value of
8/// the default toolchain.
9///
10/// This is primarily used when executing `pavex` commands that don't operate within the
11/// context of a Pavex project—e.g. `pavex new`.
12/// Otherwise the toolchain is determined by the project's `pavex` library crate version.
13pub fn get_default_pavexc(
14 locator: &PavexLocator,
15 state: &State,
16 shell: &mut Shell,
17) -> Result<PathBuf, anyhow::Error> {
18 let version = state.get_current_toolchain(shell)?;
19 let pavexc_cli_path = get_or_install_from_version(shell, locator, &version)?;
20 Ok(pavexc_cli_path)
21}