{"record":{"id":"c53925c0f9d70463","repo":"hashicorp/terraform","slug":"blank-output","errorCode":null,"errorMessage":"blank output","messagePattern":"blank output","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/cliconfig/config_unix.go","lineNumber":52,"sourceCode":"func homeDir() (string, error) {\n\t// First prefer the HOME environmental variable\n\tif home := os.Getenv(\"HOME\"); home != \"\" {\n\t\t// FIXME: homeDir gets called from globalPluginDirs during init, before\n\t\t// the logging is set up.  We should move meta initializtion outside of\n\t\t// init, but in the meantime we just need to silence this output.\n\t\t//log.Printf(\"[DEBUG] Detected home directory from env var: %s\", home)\n\n\t\treturn home, nil\n\t}\n\n\t// If that fails, try build-in module\n\tuser, err := user.Current()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif user.HomeDir == \"\" {\n\t\treturn \"\", errors.New(\"blank output\")\n\t}\n\n\treturn user.HomeDir, nil\n}\n","sourceCodeStart":34,"sourceCodeEnd":57,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/cliconfig/config_unix.go#L34-L57","documentation":"Returned by homeDir() in config_unix.go:52 when neither the HOME environment variable nor the OS user database provides a home directory (user.Current().HomeDir == \"\"). Terraform needs the home directory to locate ~/.terraformrc and ~/.terraform.d; without it, CLI config and plugin dirs cannot be resolved. This is a build of cliconfig, unix-only (the windows variant resolves differently).","triggerScenarios":"Line 34-53: os.Getenv(\"HOME\") is empty AND user.Current() succeeds but its HomeDir field is empty -> errors.New(\"blank output\"). Common in minimal containers/scratch images without a passwd entry or HOME set.","commonSituations":"Running Terraform in a Docker container (e.g. scratch/distroless) as a UID with no /etc/passwd entry and HOME unset; CI runners that strip environment variables; a misconfigured systemd unit missing 'Environment=HOME=...'.","solutions":["Set HOME explicitly: 'export HOME=/root' (or the user's real home) before running Terraform.","In Docker, run with a real user/home: '--user $(id -u):$(id -g)' plus '--env HOME=/tmp' or install the passwd entry.","Use 'TF_CLI_CONFIG_FILE' / 'TF_DATA_DIR' env vars to point Terraform at explicit config and data dirs, bypassing home-dir lookup."],"exampleFix":"# before: container with no HOME and no passwd entry\n$ terraform init  # -> blank output\n# after\n$ export HOME=/app\n$ terraform init","handlingStrategy":"validation","validationCode":"// Ensure HOME is set before running Terraform (unix).\nfunc ensureHome() error {\n    if os.Getenv(\"HOME\") == \"\" {\n        home, err := os.UserHomeDir()\n        if err != nil || home == \"\" {\n            return errors.New(\"HOME is unset and no home directory could be determined; set HOME or TF_DATA_DIR\")\n        }\n        os.Setenv(\"HOME\", home)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set HOME explicitly in containers/CI runners.","In distroless images, install a passwd entry or set TF_DATA_DIR / TF_CLI_CONFIG_FILE.","Verify the runtime user has a resolvable home directory."],"tags":["cliconfig","home-directory","environment","unix","container"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}