CopyQ icon indicating copy to clipboard operation
CopyQ copied to clipboard

Unable to use GPG support on macOS

Open jamesfreeman959 opened this issue 4 years ago • 4 comments

Before creating a new issue, see list of known issues.

Describe the bug I am using CopyQ on macOS Mojave - all is working well, but I want to use the Encryption add-on. I installed copyq using Homebrew, and then installed gnupg through Homebrew also. However on restart of CopyQ, I still see the message telling me to install GPG and restart CopyQ. The documentation details how to install GPG support on Windows and Linux, but I can't find out how to do it on macOS. I have both the gpg and gpg2 binaries available in the shell.

To Reproduce Steps to reproduce the behavior:

  1. Install copyq on macOS Mojave using Homebrew
  2. Install gnupg package using Homebrew
  3. Restart copyq
  4. See message asking for GPG to be installed for encryption support.

Expected behavior Successful install of GPG should mean Encryption options become available.

Version, OS and Environment (Get details from copyq version command if possible.)

CopyQ Clipboard Manager v3.11.1
Qt: 5.13.2
Compiler: GCC
Arch: x86_64-little_endian-lp64
OS: macOS Mojave (10.14)

Additional context Add any other context about the problem here.

jamesfreeman959 avatar Jul 08 '20 12:07 jamesfreeman959

Is gpg2 or gpg in the PATH when CopyQ is started? You can test this by opening Action dialog from the main window (F5 shortcut), typing gpg2 --version and pressing OK (it should not pop up any error notification).

Also, what does gpg2 --version print on stdout?

hluk avatar Jul 12 '20 05:07 hluk

Thanks for this @hluk - this shows that gpg2 is not on the PATH when CopyQ is started.

Is there any guidance on how best to set this up on a Mac? I've installed both CopyQ and GPG through Homebrew. CopyQ now shows up in /Applications, and starts when may machine starts (as desired).

I've tried adding /usr/local/bin to /etc/paths, and running:

sudo launchctl config user path /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

However neither of these actions have made GPG available to CopyQ.

jamesfreeman959 avatar Jul 13 '20 12:07 jamesfreeman959

I hit this wall after installing CopyQ.dmg (v. 6.1.0) and GnuPG-2.3.6.dmg on MacOS 12.4 (Monterey). Solved it with an unsatisfying hack, but at least CopyQ encryption works like it does on other platforms without exposing every other App on the machine to a PATH change.

GnuPG installed:

/usr/local/bin/gpg -> /usr/local/MacGPG2/bin/gpg2
/usr/local/MacGPG2/bin/gpg2

It also added /usr/local/MacGPG2/bin to the system default PATH, or so it appears:

% /usr/libexec/path_helper
PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/Library/Apple/usr/bin"; export PATH;

As noted elsewhere, CopyQ -> F5 could not find gpg2 (or gpg), and the PATH in effect was just /usr/bin:/bin:/usr/sbin:/sbin (Note: I use CopyQ "Autostart", but it made no difference if I exited CopyQ and re-launched).

I did not want to expose /usr/local/bin or /usr/local/MacGPG2/bin to every app in MacOS's launcher. However, when I tried tinkering with /Applications/CopyQ.app/Contents/Info.plist, I never could get any change to take effect in the launcher (not even after lsregister).

In the end, I went to folder /Applications/CopyQ.app/Contents/MacOS, renamed file CopyQ to CopyQ.exe, and replaced file CopyQ with a shell script:

#!/bin/sh
eval "$(/usr/libexec/path_helper)"
logger "$(dirname "$0")/CopyQ" "$@"
exec "$(dirname "$0")/CopyQ.exe" "$@"

The MacOS launcher doesn't know the difference, and encryption works in CopyQ just like it does on other platforms. I will likely need to revert and repeat this hack whenever CopyQ is updated.

tony-wallace avatar Jun 01 '22 19:06 tony-wallace