hasura/graphql-engine · error

can't initialise hasura project in filesystem root: %w

Error message

can't initialise hasura project in filesystem root: %w

What it means

`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.

Source

Thrown at cli/commands/init.go:199

	}

	cwdir, err := os.Getwd()
	if err != nil {
		return errors.E(op, fmt.Errorf("error getting current working directory: %w", err))
	}

	initPath, err := filepath.Abs(o.InitDir)
	if err != nil {
		return errors.E(op, err)
	}

	if initPath == cwdir {
		// check if pwd is filesystem root
		err := cli.CheckFilesystemBoundary(cwdir)
		if err != nil {
			return errors.E(
				op,
				fmt.Errorf("can't initialise hasura project in filesystem root: %w", err),
			)
		}
		// check if the current directory is already a hasura project
		err = cli.ValidateDirectory(cwdir)
		if err == nil {
			return errors.E(op, "current working directory is already a hasura project directory")
		}

		o.EC.ExecutionDirectory = cwdir
	} else {
		// create execution directory
		err := o.createExecutionDirectory()
		if err != nil {
			return errors.E(op, err)
		}
	}

	// create other required files, like config.yaml, migrations directory

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Create and cd into a dedicated project directory before init (mkdir /app && cd /app && hasura init)
  2. Pass a concrete subdirectory name: `hasura init myproject`
  3. Set the container/CI working directory to a non-root path

Example fix

// before
cd / && hasura init .
// after
mkdir -p /app && cd /app && hasura init .
Defensive patterns

Strategy: validation

Validate before calling

if initPath == "/" || filepath.Clean(cwdir) == "/" {
    log.Fatal("refusing to init at filesystem root")
}

Prevention

When it happens

Trigger: 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.

Common situations: Running as root in a container whose WORKDIR is /; misconfigured CI step cd'ing to /; passing / or an equivalent path as the project name.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/0c44c4862ce2cdb6. Report an issue: GitHub.