Problem
Creating a signed Git commit from an IntelliJ-based IDE UI (for example, Git | Commit or ⌘K / Ctrl+K) fails. The IDE log (Help | Show Log in Finder/Explorer) contains:
error: cannot run gpg: No such file or directory
error: gpg failed to sign the data:
(no gpg output)
fatal: failed to write commit object
The same git commit -S operation succeeds when run from an external terminal or from the IDE's built-in terminal. Disabling signing with git config commit.gpgSign false allows commits to complete from the IDE UI.
This applies to all IntelliJ-based IDEs (IntelliJ IDEA, PhpStorm, WebStorm, GoLand, PyCharm, RubyMine, and others) on macOS and Linux.
Cause
The IDE inherits environment variables — including PATH — from the process that launches it. When started from a graphical launcher (Dock, Spotlight, Start menu, desktop shortcut), the IDE does not run ~/.bashrc, ~/.zshrc, or similar interactive shell initialization files. As a result, the PATH exported by those files is not visible to the IDE.
The IDE's built-in terminal and any external terminal start a new shell that does load these files, which is why the same git commit -S works there.
If gpg (commonly installed at /opt/homebrew/bin/gpg or /usr/local/bin/gpg) is added to PATH only by an interactive shell init file, Git invoked by the IDE cannot locate it and signing fails.
Shell customization frameworks such as Oh My Bash, Oh My Zsh, and Powerlevel10k frequently modify or override PATH inside these interactive-only files, which exposes this difference.
Resolution
Apply one of the options below. Option 1 is the simplest persistent fix.
Option 1: Set gpg.program to an absolute path
Configure Git to invoke gpg by its full path so the IDE does not need to resolve it through PATH.
-
Locate the
gpgexecutable in a terminal:which gpg -
Configure Git globally with the path returned in step 1:
git config --global gpg.program /opt/homebrew/bin/gpg -
Restart the IDE and retry the commit.
Option 2: Launch the IDE from a terminal
Start the IDE from a shell that has already loaded the correct PATH. The IDE inherits the parent shell's environment, including the location of gpg.
See Command-line interface for JetBrains IDEs for instructions on adding the launcher script to PATH. With the launcher in place, start the IDE from a terminal session, for example:
idea
Option 3: Expose PATH to graphical sessions
Move PATH modifications out of interactive-only init files into a location that graphical sessions also load:
-
zsh: add the
export PATH=...line to~/.zshenv(read by all zsh invocations, including non-interactive ones). -
bash: add the
export PATH=...line to~/.bash_profileor~/.profile. -
macOS system-wide: add the directory containing
gpgto/etc/pathsor a file under/etc/paths.d/.
If a shell framework (such as Oh My Bash) injects its own initialization that overrides or replaces PATH for interactive sessions, ensure that the framework's source line appears after any user-added PATH exports, or move the PATH exports to one of the locations above.
After making the change, log out and log back in (or restart) so that graphical sessions pick up the new environment, then start the IDE from the desktop launcher.
Verification
After applying a fix:
-
Restart the IDE.
-
In Settings (⌘, or Ctrl+Alt+S) | Version Control | Git, click Configure GPG Keys and confirm the signing key is selected for the repository.
-
Make a test commit from Git | Commit.
-
Confirm the signature on the resulting commit:
git log --show-signature -1
Comments
0 comments
Please sign in to leave a comment.