diff --git a/CHANGELOG.md b/CHANGELOG.md index 8567b34..fbe93ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed +- The path passed to `clap_entry::init()` now points to the bundle on macOS, + rather than the DSO. - The `--verbosity` option's value now propagated to child processes when tests are run out of process. Previously the default `debug` value would always be used. diff --git a/src/plugin/library.rs b/src/plugin/library.rs index 57af62b..654a3d4 100644 --- a/src/plugin/library.rs +++ b/src/plugin/library.rs @@ -111,6 +111,15 @@ impl PluginLibrary { .unwrap_or_else(|_| PathBuf::from(".")) .join(path); + // This is the path passed to `clap_entry::init()`. On macOS this should point to the + // bundle, not the DSO. + let path_cstring = CString::new( + path.as_os_str() + .to_str() + .context("Path contains invalid UTF-8")?, + ) + .context("Path contains null bytes")?; + // NOTE: Apple says you can dlopen() bundles. This is a lie. #[cfg(target_os = "macos")] let path = { @@ -133,12 +142,6 @@ impl PluginLibrary { // The entry point needs to be initialized before it can be used. It will be deinitialized // when the `Plugin` object is dropped. let entry_point = get_clap_entry_point(&library)?; - let path_cstring = CString::new( - path.as_os_str() - .to_str() - .context("Path contains invalid UTF-8")?, - ) - .context("Path contains null bytes")?; if !unsafe_clap_call! { entry_point=>init(path_cstring.as_ptr()) } { anyhow::bail!("'clap_plugin_entry::init({path_cstring:?})' returned false."); }