From 378e91e637534859718eb711ce8a4a301eb58513 Mon Sep 17 00:00:00 2001 From: David Soria Parra Date: Fri, 16 Feb 2024 13:27:57 +0000 Subject: [PATCH] add --skip-path to rye self install This adds the option to never modify paths to rye install, even when `--yes` is provided. This addresses #620. Notable we chose to not require "--yes" for this to work, so you can have an install with prompt and still skip path. --- rye/src/cli/rye.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/rye/src/cli/rye.rs b/rye/src/cli/rye.rs index 5ab3972344..038e7a2e16 100644 --- a/rye/src/cli/rye.rs +++ b/rye/src/cli/rye.rs @@ -96,6 +96,9 @@ pub struct InstallCommand { /// Use a specific toolchain version. #[arg(long)] toolchain_version: Option, + /// Skip modifying the PATH environment variable. + #[arg(long, default_value = "false")] + skip_path: bool, } #[derive(Debug, Copy, Clone)] @@ -263,6 +266,7 @@ fn install(args: InstallCommand) -> Result<(), Error> { }, args.toolchain.as_deref(), args.toolchain_version, + args.skip_path, ) } @@ -351,6 +355,7 @@ fn perform_install( mode: InstallMode, toolchain_path: Option<&Path>, toolchain_version: Option, + skip_path: bool, ) -> Result<(), Error> { let mut config = Config::current(); let mut registered_toolchain: Option = None; @@ -547,7 +552,14 @@ fn perform_install( prompt_for_default_toolchain(registered_toolchain.unwrap(), config_doc)?; } - add_rye_to_path(&mode, shims.as_path())?; + if skip_path { + echo!( + "Skipping PATH modification. You will need to add {} to your PATH manually.", + style(shims.display()).cyan() + ); + } else { + add_rye_to_path(&mode, shims.as_path())?; + } echo!(); echo!("{}", style("All done!").green()); @@ -670,7 +682,7 @@ pub fn auto_self_install() -> Result { crate::request_continue_prompt(); } - perform_install(InstallMode::AutoInstall, None, None)?; + perform_install(InstallMode::AutoInstall, None, None, false)?; Ok(true) } }