thanos-io/thanos · error

Dir is not accessible.

Error message

Dir is not accessible.

What it means

IsDirAccessible verifies a directory exists and is readable; when os.Stat fails (path missing, permission denied, or path is on an unreachable mount) the stat error is wrapped with 'Dir is not accessible.'.

Solutions

  1. Confirm the directory exists: ls -ld <dir>
  2. Fix permissions: chown/chmod so the running user can stat/read it
  3. Ensure the volume is mounted before the process starts
  4. Correct the flag/config value that holds the wrong path

Example fix

// before
thanos tools bucket verify --objstore.config-file=... --data-dir=/missing/dir
// after
mkdir -p /var/lib/thanos/verify
thanos tools bucket verify --objstore.config-file=... --data-dir=/var/lib/thanos/verify
Defensive patterns

Strategy: validation

Validate before calling

func dirExists(path string) error {
    info, err := os.Stat(path)
    if err != nil { return err }
    if !info.IsDir() { return fmt.Errorf("%s is not a directory", path) }
    return nil
}
// call before using the dir
if err := dirExists(dataDir); err != nil { return err }

Try / catch

if err := promclient.IsDirAccessible(dataDir); err != nil {
    log.Fatalf("data dir unusable: %v", err)
}

Prevention

When it happens

Trigger: os.Stat(dir) returns an error for the directory passed to IsDirAccessible — nonexistent path or permission problem. Invoked by an anonymous caller (e.g. tooling validating a compactor/rule directory before use).

Common situations: Pointing Thanos tools at a directory that doesn't exist on the host; running the binary as a user without read permission on the data dir; directory only available after a mount that hasn't happened yet.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/15df6c56de508636. Report an issue: GitHub.

Appendix: source

Thrown at pkg/promclient/promclient.go:172

	f, err := os.Stat(filepath.Join(dir, "wal"))
	if err != nil {
		return errors.Wrap(err, errMsg)
	}

	if !f.IsDir() {
		return errors.New(errMsg)
	}

	return nil
}

// IsDirAccessible returns no error if dir can be found.
func IsDirAccessible(dir string) error {
	const errMsg = "Dir is not accessible."

	f, err := os.Stat(dir)
	if err != nil {
		return errors.Wrap(err, errMsg)
	}

	if !f.IsDir() {
		return errors.New(errMsg)
	}

	return nil
}

// ExternalLabels returns sorted external labels from /api/v1/status/config Prometheus endpoint.
// Note that configuration can be hot reloadable on Prometheus, so this config might change in runtime.
func (c *Client) ExternalLabels(ctx context.Context, base *url.URL) (labels.Labels, error) {
	u := *base
	u.Path = path.Join(u.Path, "/api/v1/status/config")

	span, ctx := tracing.StartSpan(ctx, "/prom_config HTTP[client]")
	defer span.Finish()

View on GitHub (pinned to 35b8b99117)