You are not logged in.

#1 2020-09-20 00:29:40

internatetional
Member
Registered: 2020-09-10
Posts: 3

gnupg can't write to $XDG_DATA_HOME

Hi, I was setting up Arch Linux on a new machine and wanted to use the XDG Base Directory specification to store my configuration and data files, including gnupg files, by setting the $GNUPGHOME variable to "$XDG_DATA_HOME/gnupg". This variable itself works, but I received these errors when I ran gpg --full-gen-key:

gpg: keyblock resource '/home/nate/.local/share/gnupg/pubring.kbx': No such file or directory
....
gpg: failed to create temporary file '/home/nate/.local/share/gnupg/.#lk0x000055a19e0b0a40.meliora.85933': No such file or directory
gpg: can't connect to the agent: No such file or directory
gpg: agent_genkey failed: No agent running
Key generation failed: No agent running

This command works fine and gnupg automatically creates the files and folders it needs, if I don't set $GNUPGHOME, storing its files in the default ~/.gnupg folder instead.
I learned that gnupg can't even write to the $XDG_DATA_HOME folder. What gives, and how do I solve this problem? I suppose I can make it use the ~/.gnupg folder first, and then later move the folder to $XDG_DATA_HOME, adjust its permissions, then set $GNUPGHOME to point to that new location, but is there a better, more elegant or straightforward way?

Any help would be appreciated!

Offline

#2 2020-09-20 02:31:37

solskog
Member
Registered: 2020-09-05
Posts: 462

Re: gnupg can't write to $XDG_DATA_HOME

This works for me:

$ declare -x XDG_DATA_HOME=~/.local/share
$ declare -x GNUPGHOME=$XDG_DATA_HOME/gnupg
$ mkdir -p .local/share/gnupg
$ gpg --gen-key

If gpg-agent don't start automatically:

$ gpg-agent --daemon

you also need pinentry installed of course.

Offline

#3 2020-09-20 03:42:34

merlock
Member
Registered: 2018-10-30
Posts: 262

Re: gnupg can't write to $XDG_DATA_HOME

Did you see the GnuPG entry in the wiki?

In particular, the discussion links.


Eenie meenie, chili beanie, the spirits are about to speak -- Bullwinkle J. Moose
It's a big club...and you ain't in it -- George Carlin
Registered Linux user #149839
perl -e 'print$i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10); '

Offline

Board footer

Powered by FluxBB