Skip to content

Commit 09f50c0

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
only add exe path if not using DSC_RESOURCE_PATH
1 parent 8383b18 commit 09f50c0

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ if (!$Clippy) {
222222

223223
if (!$found) {
224224
Write-Host -ForegroundCOlor Yellow "Adding $target to `$env:PATH"
225-
$env:PATH += [System.IO.Path]::PathSeparator + $target
225+
$env:PATH = $target + [System.IO.Path]::PathSeparator + $env:PATH
226226
}
227227
}
228228

dsc_lib/src/discovery/command_discovery.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::fs::File;
1414
use std::io::BufReader;
1515
use std::path::Path;
1616
use std::time::Duration;
17-
use tracing::{debug, error, warn};
17+
use tracing::{debug, error, trace, warn};
1818

1919
pub struct CommandDiscovery {
2020
}
@@ -54,13 +54,22 @@ impl CommandDiscovery {
5454
let mut resources: BTreeMap<String, DscResource> = BTreeMap::new();
5555
let mut adapter_resources: Vec<String> = Vec::new();
5656
let mut remaining_required_resource_types = required_resource_types.to_owned();
57+
let mut using_custom_path = false;
5758

5859
// try DSC_RESOURCE_PATH env var first otherwise use PATH
5960
let path_env = match env::var_os("DSC_RESOURCE_PATH") {
60-
Some(value) => value,
61+
Some(value) => {
62+
debug!("Using DSC_RESOURCE_PATH: {:?}", value.to_string_lossy());
63+
using_custom_path = true;
64+
value
65+
},
6166
None => {
67+
trace!("DSC_RESOURCE_PATH not set, trying PATH");
6268
match env::var_os("PATH") {
63-
Some(value) => value,
69+
Some(value) => {
70+
debug!("Using PATH: {:?}", value.to_string_lossy());
71+
value
72+
}
6473
None => {
6574
return Err(DscError::Operation("Failed to get PATH environment variable".to_string()));
6675
}
@@ -71,9 +80,11 @@ impl CommandDiscovery {
7180
let mut paths = env::split_paths(&path_env).collect::<Vec<_>>();
7281

7382
// add exe home to start of path
74-
if let Some(exe_home) = env::current_exe()?.parent() {
75-
debug!("Adding exe home to path: {}", exe_home.to_string_lossy());
76-
paths.insert(0, exe_home.to_path_buf());
83+
if !using_custom_path {
84+
if let Some(exe_home) = env::current_exe()?.parent() {
85+
debug!("Adding exe home to path: {}", exe_home.to_string_lossy());
86+
paths.insert(0, exe_home.to_path_buf());
87+
}
7788
}
7889

7990
for path in paths {

0 commit comments

Comments
 (0)