Software⏱️ 3 min read📅 2026-06-11

How to Fix: GNUPG2 suddenly throwing "Error building skey array: No such file or directory"

GNUPG2 error building skey array: No such file or directory.

Quick Answer: The issue is likely due to the missing or invalid permissions for the ~/.gnupg/private-keys-v1.d directory. Try setting the correct permissions using chmod 700 ~/.gnupg/private-keys-v1.d.

GNUPG2 has thrown an error message 'Error building skey array: No such file or directory' which is frustrating for users of the project that uses gnupg2 to encrypt data.

This issue affects users who are using gnupg2 in their CI scripts and have encountered this error message, making it difficult to manage sensitive data.

🛑 Root Causes of the Error

  • The primary reason for this error is due to the missing or invalid permissions of the ~/.gnupg/private-keys-v1.d directory. This directory is necessary for gnupg2 to store its private keys and build the skey array.
  • Another possible cause could be that the GPG_TTY environment variable is not set correctly, which can lead to gnupg2 being unable to find the required files or directories.

✅ Best Solutions to Fix It

Setting Correct Permissions

  1. Step 1: To resolve this issue, you need to correct the permissions of the ~/.gnupg/private-keys-v1.d directory. Run the following command in your CI script: $ mkdir -p ~/.gnupg/private-keys-v1.d
  2. Step 2: Next, change the ownership of the directory to the current user using the following command: $ chown $USER:$USER ~/.gnupg/private-keys-v1.d
  3. Step 3: Finally, set the permissions of the directory to 700 (read and write for the owner only) using the following command: $ chmod 700 ~/.gnupg/private-keys-v1.d

Setting GPG_TTY Environment Variable

  1. Step 1: If setting the permissions of the directory does not resolve the issue, you may need to set the GPG_TTY environment variable correctly. Run the following command in your CI script: $ export GPG_TTY=$(tty)
  2. Step 2: This sets the GPG_TTY variable to the current terminal, which is necessary for gnupg2 to function correctly.

💡 Conclusion

By setting the correct permissions of the ~/.gnupg/private-keys-v1.d directory and ensuring that the GPG_TTY environment variable is set correctly, you should be able to resolve the 'Error building skey array: No such file or directory' error message in your CI script.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions