Repository navigation
#2019: on macOS, find pdfcraft-cli and photocraft-cli where Homebrew installs them - #2248
Conversation
…mebrew installs them PdfCraft's Mac app doesn't carry its CLI, and an app started from the Finder or the Dock has launchd's short PATH, without Homebrew's folders, so attachment previews were never offered on a Mac with the CLI installed by `brew install pdfcraft-cli`. Look in /opt/homebrew/bin (Apple silicon) and then /usr/local/bin (Intel), after the app bundle and before PATH. PRIVACY.md names both folders. Human-reviewed, AI-assisted, nobody's mailbox harmed.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
vangel76
left a comment
There was a problem hiding this comment.
Checked renderer discovery, macOS candidate order, preview availability and process launch, the path-order tests, and current main.
Source review only. I did not build the project, run tests, or check CI.
|
|
||
| /// The helper `name` in the first of `dirs` that has it. | ||
| fn first_in(dirs: impl IntoIterator<Item = PathBuf>, name: &str) -> Option<PathBuf> { | ||
| dirs.into_iter().map(|dir| dir.join(name)).find_map(absolute_file) |
There was a problem hiding this comment.
P3. Skip non-executable files in Homebrew's helper locations
A non-executable PDFCraft CLI left in /usr/local/bin, for example after copying it without execute permissions, now wins over a working copy on PATH. absolute_file accepts any regular file, so Options offers previews, but the selected helper fails at process launch. On macOS, skip auto-discovered candidates without execute permission and continue the lookup. Update the path-order test to use executable helpers and include a non-executable earlier candidate.
There was a problem hiding this comment.
Right. Fixed in 0940720: first_in now passes over a helper with none of its execute bits set and looks in the next folder, then on PATH. The path-order test writes executable helpers, and a new test, a_helper_that_may_not_be_run_is_passed_over (Unix only), puts non-executable copies in the bundle and Apple silicon folders ahead of a working one in the Intel folder. It fails without the change.
Human-reviewed, AI-assisted, nobody's mailbox harmed.
A pdfcraft-cli without execute permission in /usr/local/bin, copied there without it, say, was taken over a working copy on PATH: absolute_file takes any regular file, so Options offered previews, and the helper then failed as it was started (vangel76 on UCSLabs#2248). first_in, which looks in the app bundle and Homebrew's folders, now passes over a file with none of its execute bits set and looks in the next folder, then on PATH. The path-order test writes executable helpers, and a_helper_that_may_not_be_run_is_passed_over puts non-executable copies ahead of a working one. Human-reviewed, AI-assisted, nobody's mailbox harmed.
|
vangel76
left a comment
There was a problem hiding this comment.
I verified that the macOS lookup now passes over helper files with no execute bits and continues to the remaining locations. The source test includes an earlier non-executable file and a working helper later in the lookup.
Source review only. I did not build the project, run tests, or check CI.



Closes #2019
What changes for the person using MailCraft
On a Mac, File › Options now offers attachment previews when PdfCraft's or PhotoCraft's command-line tool was installed with Homebrew (
brew install pdfcraft-cli,brew install photocraft-cli; both formulae are in homebrew-core).Before, MailCraft looked in
/Applications/<program>.app/Contents/MacOSand then onPATH, and neither finds a Homebrew install:packaging/macos/package.shships the CLI as a separate zip.PATH, which doesn't include Homebrew's folders.MailCraft now looks in
/opt/homebrew/bin(Apple silicon) and then/usr/local/bin(Intel), after the app bundle and beforePATH.MAILCRAFT_PDFCRAFT_CLIandMAILCRAFT_PHOTOCRAFT_CLIstill come first.PRIVACY.mdnames both folders.PATH(vangel76's review).Changes a default: no
How it was checked
New test
attachment_render::tests::the_first_folder_that_has_the_helper_wins. With three folders (bundle, Apple silicon, Intel):It writes executable helpers and uses the platform's executable suffix, so it runs on every platform.
New test
attachment_render::tests::a_helper_that_may_not_be_run_is_passed_over(Unix only): non-executable copies in the bundle and Apple silicon folders are passed over for a working one in the Intel folder, and with only a non-executable copy left nothing is found. It fails without the change.macOS 26.6 (Apple silicon), Rust 1.98.1:
cargo xtask cipasses all 15 steps with #2189: clippy passes on macOS: pin_for is used on Linux and FreeBSD alone #2190'spin_forfix applied locally. This branch doesn't include that fix.Not tried end to end with Homebrew's own
pdfcraft-cliinstalled, and not built on Windows or Linux.cargo xtask cipassesA crash or data-loss fix has its regression test (not one)
"Allow edits by maintainers": the fork belongs to an organisation, where GitHub doesn't offer that box. If you'd like to push to this branch, say so and you'll have write access to
easier-digital/mailcraft.I have signed the CLA, or will by commenting on this pull request
Human-reviewed, AI-assisted, nobody's mailbox harmed.
Summary by CodeRabbit
PATH. Unusable tools are skipped so the search can continue to another available installation.