{"record":{"id":"0c44c4862ce2cdb6","repo":"hasura/graphql-engine","slug":"can-t-initialise-hasura-project-in-filesystem-root","errorCode":null,"errorMessage":"can't initialise hasura project in filesystem root: %w","messagePattern":"can't initialise hasura project in filesystem root: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/init.go","lineNumber":199,"sourceCode":"\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)\n\t\tif err == nil {\n\t\t\treturn errors.E(op, \"current working directory is already a hasura project directory\")\n\t\t}\n\n\t\to.EC.ExecutionDirectory = cwdir\n\t} else {\n\t\t// create execution directory\n\t\terr := o.createExecutionDirectory()\n\t\tif err != nil {\n\t\t\treturn errors.E(op, err)\n\t\t}\n\t}\n\n\t// create other required files, like config.yaml, migrations directory","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/init.go#L181-L217","documentation":"`hasura init` refuses to initialise a project in the filesystem root. When the resolved init path equals the CWD, the CLI calls cli.CheckFilesystemBoundary; if the CWD is / (or crosses the boundary), init aborts to avoid writing project files at the filesystem root.","triggerScenarios":"Running `hasura init .` or `hasura init` with default directory while the CWD resolves to /, or specifying an init dir that resolves to the filesystem root.","commonSituations":"Running as root in a container whose WORKDIR is /; misconfigured CI step cd'ing to /; passing / or an equivalent path as the project name.","solutions":["Create and cd into a dedicated project directory before init (mkdir /app && cd /app && hasura init)","Pass a concrete subdirectory name: `hasura init myproject`","Set the container/CI working directory to a non-root path"],"exampleFix":"// before\ncd / && hasura init .\n// after\nmkdir -p /app && cd /app && hasura init .","handlingStrategy":"validation","validationCode":"if initPath == \"/\" || filepath.Clean(cwdir) == \"/\" {\n    log.Fatal(\"refusing to init at filesystem root\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always init inside a dedicated project subdirectory","Set container WORKDIR to /app, not /"],"tags":["hasura","cli","init","filesystem-root","guard"],"backgroundTag":"invalid-project-path","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}