Skip to content

Commit

Permalink
doctor: allow shims on PATH to hide inactive problem
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Sep 25, 2023
1 parent 962e615 commit 514adbe
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() {

Check warning on line 65 in src/cli/doctor.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/doctor.rs#L65

Added line #L65 was not covered by tests
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();

Check warning on line 68 in src/cli/doctor.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/doctor.rs#L68

Added line #L68 was not covered by tests
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."#

Check warning on line 73 in src/cli/doctor.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/doctor.rs#L71-L73

Added lines #L71 - L73 were not covered by tests
));
}

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

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

Check warning on line 95 in src/cli/doctor.rs

View check run for this annotation

Codecov / codecov/patch

src/cli/doctor.rs#L93-L95

Added lines #L93 - L95 were not covered by tests

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 514adbe

Please sign in to comment.