From 4d9d303c5617de9dfdd22be91f2f30c02a7b85d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NEDJAR?= Date: Tue, 28 Apr 2026 11:48:17 +0200 Subject: [PATCH 1/2] fix: add /scripts to OpenOCD search path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The xpack-bundled OpenOCD release archive ships its standard scripts under /scripts/ (interface/, target/, ...). Our .cfg files reference these via `source [find interface/stlink.cfg]` etc., which resolves only through OpenOCD's search path. A previous cleanup commit dropped the `-s scripts` argument, thinking it was a leftover from the old script-dir layout — it wasn't. Without that path, the bundled OpenOCD has to fall back to its compiled-in install prefix, which doesn't match the flat layout the release archive produces. Restore the search path with an absolute resolution against exe_dir, guarded by an `is_dir()` check so a system-OpenOCD install (where `/scripts/` doesn't exist) keeps using OpenOCD's defaults. Closes #8. --- src/open_ocd_task.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/open_ocd_task.rs b/src/open_ocd_task.rs index 948e9a1..e81fe17 100644 --- a/src/open_ocd_task.rs +++ b/src/open_ocd_task.rs @@ -123,7 +123,7 @@ where .into_string() .map_err(|_| "Failed to convert tmp_dir to string.")?; - let cmd = cmd.args(&[ + cmd.args(&[ "-s", &config_folder, "-s", @@ -132,6 +132,19 @@ where &ws_foler, ]); + // The xpack-bundled OpenOCD ships its standard scripts alongside the + // executable in `/scripts/`. Our .cfg files reference these via + // `source [find interface/...]`, which only resolves through OpenOCD's + // search path — add the directory if it exists. + let scripts_folder = dirs::get_exe_dir()?.join("scripts"); + if scripts_folder.is_dir() { + let scripts_str = scripts_folder + .into_os_string() + .into_string() + .map_err(|_| "Failed to convert scripts path to string")?; + cmd.args(&["-s", &scripts_str]); + } + let mut child = cmd .stdout(Stdio::piped()) .stderr(Stdio::piped()) From 568e3869130ae520f30075a05169e5edb19892a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NEDJAR?= Date: Tue, 28 Apr 2026 12:07:49 +0200 Subject: [PATCH 2/2] fix: pass scripts path as PathBuf instead of converting to UTF-8 Command::arg accepts OsStr/Path directly, so the into_os_string() + into_string() conversion was both unnecessary and a panic vector on non-UTF-8 paths. Per Copilot review on PR #11. --- src/open_ocd_task.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/open_ocd_task.rs b/src/open_ocd_task.rs index e81fe17..e75a4fe 100644 --- a/src/open_ocd_task.rs +++ b/src/open_ocd_task.rs @@ -138,11 +138,7 @@ where // search path — add the directory if it exists. let scripts_folder = dirs::get_exe_dir()?.join("scripts"); if scripts_folder.is_dir() { - let scripts_str = scripts_folder - .into_os_string() - .into_string() - .map_err(|_| "Failed to convert scripts path to string")?; - cmd.args(&["-s", &scripts_str]); + cmd.arg("-s").arg(&scripts_folder); } let mut child = cmd