{"record":{"id":"1266f44f6b66216d","repo":"hasura/graphql-engine","slug":"error-getting-current-working-directory-w","errorCode":null,"errorMessage":"error getting current working directory: %w","messagePattern":"error getting current working directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/init.go","lineNumber":185,"sourceCode":"\n\tif o.Endpoint != \"\" && !o.GetMetadataMigrations && o.EC.IsTerminal {\n\t\tr, err := util.GetYesNoPrompt(\n\t\t\tfmt.Sprintf(\"Initialize project with metadata & migrations from %s ?\", o.Endpoint),\n\t\t)\n\t\tif err != nil {\n\t\t\treturn errors.E(op, fmt.Errorf(\"prompt exited: %w\", err))\n\t\t}\n\n\t\to.GetMetadataMigrations = r\n\t}\n\n\tif !o.EC.IsTerminal {\n\t\to.GetMetadataMigrations = true\n\t}\n\n\tcwdir, err := os.Getwd()\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"error getting current working directory: %w\", err))\n\t}\n\n\tinitPath, err := filepath.Abs(o.InitDir)\n\tif err != nil {\n\t\treturn errors.E(op, err)\n\t}\n\n\tif initPath == cwdir {\n\t\t// check if pwd is filesystem root\n\t\terr := cli.CheckFilesystemBoundary(cwdir)\n\t\tif err != nil {\n\t\t\treturn errors.E(\n\t\t\t\top,\n\t\t\t\tfmt.Errorf(\"can't initialise hasura project in filesystem root: %w\", err),\n\t\t\t)\n\t\t}\n\t\t// check if the current directory is already a hasura project\n\t\terr = cli.ValidateDirectory(cwdir)","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/init.go#L167-L203","documentation":"os.Getwd() failed inside `hasura init`. The CLI resolves the current working directory before computing absolute init paths; failure means the process CWD was deleted or is unreadable (ENOENT/EACCES).","triggerScenarios":"Running `hasura init` from a directory that has been deleted while the shell still points at it, or with insufficient permission to traverse the CWD path.","commonSituations":"Deleted terminal working directory (common after rm -rf of the dir you're in); container/sandbox oddities where CWD is unlinked; overly restrictive directory modes.","solutions":["cd into an existing directory and re-run `hasura init`","Verify the shell's CWD exists (pwd) and is traversable","Check directory permissions on parent paths if access is denied"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if wd, err := os.Getwd(); err != nil {\n    log.Fatal(\"working directory unavailable; cd to a valid dir\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["cd to a fresh directory before running init","Avoid deleting the shell's CWD in scripts"],"tags":["hasura","cli","init","getwd","filesystem"],"backgroundTag":"working-directory-unavailable","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}