{"record":{"id":"33be19fa109febd1","repo":"hasura/graphql-engine","slug":"error-finding-absolute-path-for-project-directory","errorCode":null,"errorMessage":"error finding absolute path for project directory: %w","messagePattern":"error finding absolute path for project directory: %w","errorType":"exception","errorClass":"errors.Error","httpStatus":null,"severity":"error","filePath":"cli/directory.go","lineNumber":40,"sourceCode":"// found to have these files, ExecutionDirectory is set as that directory.\nfunc (ec *ExecutionContext) validateDirectory() error {\n\tvar (\n\t\top  errors.Op = \"cli.ExecutionContext.validateDirectory\"\n\t\terr error\n\t)\n\tif len(ec.ExecutionDirectory) == 0 {\n\t\tcwd, err := os.Getwd()\n\t\tif err != nil {\n\t\t\treturn errors.E(op, fmt.Errorf(\"error getting current working directory: %w\", err))\n\t\t}\n\n\t\tec.ExecutionDirectory = cwd\n\t} else {\n\t\tec.ExecutionDirectory, err = filepath.Abs(ec.ExecutionDirectory)\n\t\tif err != nil {\n\t\t\treturn errors.E(\n\t\t\t\top,\n\t\t\t\tfmt.Errorf(\"error finding absolute path for project directory: %w\", err),\n\t\t\t)\n\t\t}\n\t}\n\n\ted, err := os.Stat(ec.ExecutionDirectory)\n\tif err != nil {\n\t\tif stderrors.Is(err, fs.ErrNotExist) {\n\t\t\treturn errors.E(op, fmt.Errorf(\"did not find required directory. use 'init'?: %w\", err))\n\t\t}\n\n\t\treturn errors.E(op, fmt.Errorf(\"error getting directory details: %w\", err))\n\t}\n\n\tif !ed.IsDir() {\n\t\treturn errors.E(op, fmt.Errorf(\"'%s' is not a directory: %w\", ed.Name(), err))\n\t}\n\t// config.yaml\n\t// migrations/","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/directory.go#L22-L58","documentation":"Thrown by validateDirectory when filepath.Abs fails to convert the configured execution directory into an absolute path. This wraps the underlying stdlib error and means the CLI cannot establish a canonical working directory before validating the project layout. In practice it almost never fires on healthy systems since Abs only fails when os.Getwd fails.","triggerScenarios":"Calling Validate (or any CLI command that triggers it) with ec.ExecutionDirectory set to a relative path while the process's current working directory has been deleted or become unreadable, causing filepath.Abs -> os.Getwd to return an error.","commonSituations":"Running the CLI from a terminal whose cwd was deleted (e.g. after a build script rm -rf's its own directory), in containers where the workdir was removed, or after a branch switch removed the current directory.","solutions":["Verify the directory you're running from still exists (pwd or ls .); recreate it or cd elsewhere and retry","Pass an explicit absolute --directory/project flag so Abs does not depend on the process cwd","Check for scripts or CI steps that delete the working directory before invoking the CLI"],"exampleFix":"# before\n./mycli --dir ./project run   # run from a deleted cwd\n# after\ncd /tmp && ./mycli --dir /home/user/project run","handlingStrategy":"validation","validationCode":"dir := os.Getenv(\"PROJECT_DIR\")\nabs, err := filepath.Abs(dir)\nif err != nil {\n    log.Fatalf(\"cannot resolve %q to an absolute path: %v\", dir, err)\n}\nif _, err := os.Stat(abs); err != nil {\n    log.Fatalf(\"execution directory unusable: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := ec.Validate(); err != nil {\n    if strings.Contains(err.Error(), \"error finding absolute path\") {\n        // cwd or path resolution is broken; re-run from an existing directory with an absolute path\n    }\n    return err\n}","preventionTips":["Always pass an absolute directory path to the CLI in scripts and CI","Avoid running commands from directories that build scripts might delete","Fail fast in wrappers: verify cwd exists before invoking the tool"],"tags":["filesystem","working-directory","path-resolution","go"],"backgroundTag":"working-directory-deleted","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}