Skip to content

macOS: ExternalCommandFailed: External command failed with exit code 1! Command: find -type f -name '*.gpg' -print0 #5

@stewmehr

Description

@stewmehr

This repo has seen little activity over the last four to five years so I am not sure if it is still actively maintained. This is why I will suggest different solutions that

  • leave the code as is and instead focus on client side configuration or
  • make some tiny modifications in the python-qpass code.

Background on the error

macOS ships with a different find command (BSD find) than the one pre-installed on most Linux distributions (GNU find). One key difference is that GNU find automatically defaults to the current directory when searching for files - BSD find, on the other hand, requires a mandatory path argument.

To run a recursive search of all password entries contained in the password store python-qpass uses the following command:

find -type f -name '*.gpg' -print0

As no path argument is provided, this command will

  • default to the password store directory on Linux
  • fail on macOS.

The following potential fixes should all work. My personal preference is on 3.

Solution 1: Install GNU find, rearrange $PATH

Install GNU find via

brew install findutils

and follow the instructions provided in this Stack Overflow answer. You now have access to BSD find (via find) as well as GNU find (via gfind). If you have set up your $PATH variable correctly, all calls to find should now use GNU find.

Solution 2: Install GNU find, modify python-qpass to use GNU find instead

Install GNU find via

brew install findutils

and leave your $PATH as is. You now have access to BSD find (via find) as well as GNU find (via gfind). All you need to do is tell python-qpass to use gfind instead of find if you are on macOS.

Change this line

listing = self.context.capture("find", "-type", "f", "-name", "*.gpg", "-print0")

to

+        find_command = "gfind" if platform.system().lower() == "darwin" else "find"
-        listing = self.context.capture("find", "-type", "f", "-name", "*.gpg", "-print0")
+        listing = self.context.capture(find_command, "-type", "f", "-name", "*.gpg", "-print0")

Solution 3: Modify python-qpass to provide path argument

Provide the required path argument to find. This will fix the issue on macOS and will not have any effect on Linux (where the path argument is optional).

Change this line

listing = self.context.capture("find", "-type", "f", "-name", "*.gpg", "-print0")

to

-        listing = self.context.capture("find", "-type", "f", "-name", "*.gpg", "-print0")
+        listing = self.context.capture("find", self.directory, "-type", "f", "-name", "*.gpg", "-print0")

I am planning to submit a pull request containing this last solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions