{"record":{"id":"79282c7ba16661b4","repo":"getsops/sops","slug":"failed-to-create-new-gnupg-home-w","errorCode":null,"errorMessage":"failed to create new GnuPG home: %w","messagePattern":"failed to create new GnuPG home: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgp/keysource.go","lineNumber":125,"sourceCode":"\t}\n\tfor _, s := range strings.Split(fingerprint, \",\") {\n\t\tkeys = append(keys, NewMasterKeyFromFingerprint(s))\n\t}\n\treturn keys\n}\n\n// GnuPGHome is the absolute path to a GnuPG home directory.\n// A new keyring can be constructed by combining the use of NewGnuPGHome() and\n// Import() or ImportFile().\ntype GnuPGHome string\n\n// NewGnuPGHome initializes a new GnuPGHome in a temporary directory.\n// The caller is expected to handle the garbage collection of the created\n// directory.\nfunc NewGnuPGHome() (GnuPGHome, error) {\n\ttmpDir, err := os.MkdirTemp(\"\", \"sops-gnupghome-\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to create new GnuPG home: %w\", err)\n\t}\n\treturn GnuPGHome(tmpDir), nil\n}\n\n// Import attempts to import the armored key bytes into the GnuPGHome keyring.\n// It returns an error if the GnuPGHome does not pass Validate, or if the\n// import failed.\n//\n// Consider using ImportContext instead.\nfunc (d GnuPGHome) Import(armoredKey []byte) error {\n\treturn d.ImportContext(context.Background(), armoredKey)\n}\n\n// ImportContext attempts to import the armored key bytes into the GnuPGHome keyring.\n// It returns an error if the GnuPGHome does not pass Validate, or if the\n// import failed.\nfunc (d GnuPGHome) ImportContext(ctx context.Context, armoredKey []byte) error {\n\tif err := d.Validate(); err != nil {","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/getsops/sops/blob/13442bb98183887d7a9ac09ec8ab0564673a59d8/pgp/keysource.go#L107-L143","documentation":"NewGnuPGHome creates a temporary directory (os.MkdirTemp with prefix 'sops-gnupghome-') to serve as an isolated GNUPGHOME. This error wraps a failure of MkdirTemp itself, meaning the OS refused to create the temp directory. It is rare and points to filesystem or environment problems with the temp directory.","triggerScenarios":"Calling NewGnuPGHome (directly or via tests/helpers) when os.MkdirTemp(\"\", \"sops-gnupghome-\") fails because TMPDIR is unwritable/nonexistent, the disk is full, or permission bits on the temp base directory forbid creation.","commonSituations":"TMPDIR pointing to a read-only or deleted directory; running as a user without write access to /tmp; disk quota/full disk in CI runners.","solutions":["Check that $TMPDIR (or /tmp) exists and is writable: `ls -ld $TMPDIR /tmp`, then fix permissions or unset a bad TMPDIR.","Free disk space / raise quota if the filesystem is full.","Run `mktemp -d` manually to confirm temp creation works in your environment.","If TMPDIR must be nonstandard, set TMPDIR to a writable absolute path before running the program/tests."],"exampleFix":"// before\nexport TMPDIR=/readonly/dir\n// after\nexport TMPDIR=/tmp  # must exist and be writable by the current user","handlingStrategy":"try-catch","validationCode":"// Go: check temp dir writability before creating a GnuPG home\nd := os.Getenv(\"TMPDIR\"); if d == \"\" { d = os.TempDir() }\nif fi, err := os.Stat(d); err != nil || !fi.IsDir() {\n  return fmt.Errorf(\"temp dir %q unusable: %w\", d, err)\n}","typeGuard":null,"tryCatchPattern":"// Go\nhome, err := pgp.NewGnuPGHome()\nif err != nil {\n  return fmt.Errorf(\"cannot create GnuPG home (check TMPDIR/disk space): %w\", err)\n}","preventionTips":["Keep TMPDIR pointing at a writable absolute directory in CI and containers","Monitor disk space/quota on build runners","Smoke-test `mktemp -d` in environment setup scripts"],"tags":["gnupg","pgp","filesystem","tempdir"],"backgroundTag":"temp-dir-creation-failed","analyzedSha":"13442bb98183887d7a9ac09ec8ab0564673a59d8","analyzedAt":"2026-09-01T03:53:00.447Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}