Skip to content

Commit

Permalink
doctor: allow shims on PATH to hide inactive problem (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx authored Sep 25, 2023
1 parent 962e615 commit c3de328
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/cli/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::output::Output;
use crate::plugins::PluginType;
use crate::shell::ShellType;
use crate::toolset::ToolsetBuilder;
use crate::{cli, cmd};
use crate::{cli, cmd, dirs};
use crate::{duration, env};

/// Check rtx installation for possible problems.
Expand Down Expand Up @@ -62,12 +62,15 @@ impl Command for Doctor {
));
}

if !config.is_activated() {
if !config.is_activated() && !shims_on_path() {
let cmd = style("rtx help activate").yellow().for_stderr();
let url = style("https://rtx.pub").underlined().for_stderr();
let shims = style(dirs::SHIMS.display()).cyan().for_stderr();
checks.push(formatdoc!(
r#"rtx is not activated, run {cmd} or
read documentation at {url} for activation instructions"#
read documentation at {url} for activation instructions.
Alternatively, add the shims directory {shims} to PATH.
Using the shims directory is preferred for non-interactive setups."#
));
}

Expand All @@ -87,6 +90,10 @@ impl Command for Doctor {
}
}

fn shims_on_path() -> bool {
env::PATH.contains(&*dirs::SHIMS)
}

fn rtx_data_dir() -> String {
let mut s = style("rtx data directory:\n").bold().to_string();
s.push_str(&format!(" {}\n", env::RTX_DATA_DIR.to_string_lossy()));
Expand Down

0 comments on commit c3de328

Please sign in to comment.