{"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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/cliconfig/config_unix.go#L34-L57","documentation":"Returned at config_unix.go:52 when Terraform's home-directory resolution falls back to os/user.Current() on Unix systems and the returned user struct has an empty HomeDir field. This indicates a broken or misconfigured user database (e.g., /etc/passwd missing the home directory entry). The error 'blank output' means the OS reported a user but with no home directory path.","triggerScenarios":"On Unix/Linux, the HOME environment variable is not set (the earlier env-var check failed), so the code falls back to user.Current(). The OS returns a user record, but HomeDir is empty — typically due to a malformed /etc/passwd entry or running in a minimal container/sandbox without proper user setup.","commonSituations":"Running terraform in minimal Docker containers with broken user setup; chroot or sandboxed environments without /etc/passwd; system accounts with no home directory; misconfigured LDAP/NIS user databases.","solutions":["Set the HOME environment variable explicitly: 'export HOME=/root' or the appropriate path.","Fix the /etc/passwd entry for the current user to include a valid home directory.","In Docker, ensure the user has a proper home directory: 'USER root' or add 'usermod -d /home/user user'.","Set TF_DATA_DIR to a known path to reduce dependency on home directory resolution."],"exampleFix":"# before: HOME unset, /etc/passwd broken\nterraform init\n// error: blank output\n\n# after: set HOME explicitly\nexport HOME=/root\nterraform init","handlingStrategy":"validation","validationCode":"// Validate HOME is set before running terraform:\n// if os.Getenv(\"HOME\") == \"\" {\n//     os.Setenv(\"HOME\", \"/root\") // or appropriate path\n// }\n// exec.Command(\"terraform\", \"init\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set HOME in Docker containers and CI environments.","Ensure /etc/passwd has valid home directory entries for all users.","Set TF_DATA_DIR as an alternative to relying on home directory resolution.","Validate user configuration in container images before running terraform."],"tags":["terraform","cli","home-directory","unix","environment","container"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}