diff --git a/rye/src/cli/rye.rs b/rye/src/cli/rye.rs index 5ab3972344..9006832428 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_modify_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_modify_path, ) } @@ -351,6 +355,7 @@ fn perform_install( mode: InstallMode, toolchain_path: Option<&Path>, toolchain_version: Option, + skip_modify_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_modify_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) } }