Skip to content

Commit

Permalink
add --skip-modify-path to rye self install
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dsp committed Feb 16, 2024
1 parent 15fc50b commit d97a5f3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions rye/src/cli/rye.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ pub struct InstallCommand {
/// Use a specific toolchain version.
#[arg(long)]
toolchain_version: Option<PythonVersionRequest>,
/// Skip modifying the PATH environment variable.
#[arg(long, default_value = "false")]
skip_modify_path: bool,
}

#[derive(Debug, Copy, Clone)]
Expand Down Expand Up @@ -263,6 +266,7 @@ fn install(args: InstallCommand) -> Result<(), Error> {
},
args.toolchain.as_deref(),
args.toolchain_version,
args.skip_modify_path,
)
}

Expand Down Expand Up @@ -351,6 +355,7 @@ fn perform_install(
mode: InstallMode,
toolchain_path: Option<&Path>,
toolchain_version: Option<PythonVersionRequest>,
skip_modify_path: bool,
) -> Result<(), Error> {
let mut config = Config::current();
let mut registered_toolchain: Option<PythonVersionRequest> = None;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -670,7 +682,7 @@ pub fn auto_self_install() -> Result<bool, Error> {
crate::request_continue_prompt();
}

perform_install(InstallMode::AutoInstall, None, None)?;
perform_install(InstallMode::AutoInstall, None, None, false)?;
Ok(true)
}
}

0 comments on commit d97a5f3

Please sign in to comment.