From 2089c035d05bea86905d427ec6ddd10a1e2c5ab4 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 13 Aug 2023 14:30:04 +0200 Subject: [PATCH] [yabridge] Warn on non-executable yabridge files --- CHANGELOG.md | 3 ++- tools/yabridgectl/src/config.rs | 5 ++++- tools/yabridgectl/src/util.rs | 25 ++++++++++++++++++++----- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82a19549..6fb3e3c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ### yabridgectl - Some outdated warning messages have been updated to make yabridge's current - state. + state. There are also additional warnings when detecting common installation + issues. ### Packaging notes diff --git a/tools/yabridgectl/src/config.rs b/tools/yabridgectl/src/config.rs index 051ae584..da5f4ff5 100644 --- a/tools/yabridgectl/src/config.rs +++ b/tools/yabridgectl/src/config.rs @@ -304,7 +304,10 @@ impl Config { }; // `yabridge-host.exe` should either be in the search path, or it should be in - // `~/.local/share/yabridge` (which was appended to the `$PATH` at the start of `main()`) + // `~/.local/share/yabridge` (which was appended to the `$PATH` at the start of `main()`). + // `which()` also ensures that the files are executable. Some methods of extracting and + // copying archive strip the executable bit, in which case they will show up as not found + // here. let yabridge_host_exe = which(YABRIDGE_HOST_EXE_NAME).ok(); let yabridge_host_exe_so = yabridge_host_exe .as_ref() diff --git a/tools/yabridgectl/src/util.rs b/tools/yabridgectl/src/util.rs index 09659029..258ce501 100644 --- a/tools/yabridgectl/src/util.rs +++ b/tools/yabridgectl/src/util.rs @@ -231,11 +231,26 @@ pub fn verify_path_setup() -> Result { // First we'll check `~/.local/share/yabridge`, since that's a special location where yabridge // will always search let xdg_data_yabridge = config::yabridge_directories().map(|dirs| dirs.get_data_home()); - let xdg_data_yabridge_exists = xdg_data_yabridge - .map(|data_home| data_home.join(YABRIDGE_HOST_EXE_NAME).is_executable()) - .unwrap_or(false); - if xdg_data_yabridge_exists { - return Ok(true); + let xdg_yabridge_host_exe_path = + xdg_data_yabridge.map(|data_home| data_home.join(YABRIDGE_HOST_EXE_NAME)); + match xdg_yabridge_host_exe_path { + Ok(path) if path.is_executable() => return Ok(true), + // If the file does exist but is not executable, it's almost certainly a mistake. This has + // happened once or twice before. Some archive extraction programs seem to strip the + // executable bits. + Ok(path) if path.exists() => { + eprintln!( + "\n{}", + wrap(&format!( + "WARNING: '{}' exists but is not executable. Something probably went wrong \ + when extracting yabridge's files.", + path.display().to_string().bright_white(), + )) + ); + + return Ok(false); + } + _ => (), } // Then we'll check the login shell, since DAWs launched from the GUI will have the same