thanos-io/thanos · error
unable to access path
Error message
unable to access path '%s'
What it means
This error is returned by the `thanos tools bucket upload` command when the directory specified by the --path flag cannot be accessed. The command calls promclient.IsDirAccessible on tbc.path before shipping local blocks to object storage; if that check fails, the underlying stat/open error is wrapped with the target path. It means the process either cannot see the directory or it is not a readable directory.
Solutions
- Verify the path exists and is a directory: ls -ld <path>; correct the --path value if there is a typo
- Check filesystem permissions (ls -ld each path component) and run the tool as a user with read/execute access, or fix ownership with chown/chmod
- If running in Kubernetes/Docker, confirm the data directory is mounted into the container at the same path
- Ensure you point at the block storage directory (TSDB dir), not a single block or meta.json file
Example fix
// before thanos tools bucket upload --path /var/thanos/typo-dir --objstore.bucket.config-file=bucket.yaml // after thanos tools bucket upload --path /var/thanos/store-dir --objstore.bucket.config-file=bucket.yaml
Defensive patterns
Strategy: validation
Validate before calling
info, err := os.Stat(path)
if err != nil {
return fmt.Errorf("path %q not accessible: %w", path, err)
}
if !info.IsDir() {
return fmt.Errorf("%q is not a directory", path)
}
// also ensure readability:
if f, err := os.Open(path); err != nil {
return fmt.Errorf("directory %q not readable: %w", path, err)
} else {
f.Close()
} Prevention
- Always pass an absolute path to --path to avoid relative-path surprises
- Pre-flight check with `ls -ld <path>` before running the tool, especially in containers
- Ensure the data directory is mounted in containerized deployments
- Run the tool as a user with read/execute permissions on the TSDB data directory
When it happens
Trigger: Running `thanos tools bucket upload --path <dir>` where the path does not exist, is a regular file instead of a directory, the path contains a typo or relative-path mistake, or the OS user running thanos lacks read/execute permission on the directory or a parent.
Common situations: Typos in --path; running the tool inside a container where the data directory was not volume-mounted; running as a non-root user without permissions on the Prometheus data dir; pointing at a file (e.g. a block meta.json) instead of the directory; wrong working directory when using a relative path.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- invalid reload method
- unable to open tbc directory
- failed to parse template
- failed to execute template
- failed to parse the template
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/4ab3e7e094931d64.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/thanos/tools_bucket.go:1473
}
func registerBucketUploadBlocks(app extkingpin.AppClause, objStoreConfig *extflag.PathOrContent) {
cmd := app.Command("upload-blocks", "Upload blocks push blocks from the provided path to the object storage.")
tbc := &bucketUploadBlocksConfig{}
tbc.registerBucketUploadBlocksFlag(cmd)
cmd.Setup(func(g *run.Group, logger log.Logger, reg *prometheus.Registry, _ opentracing.Tracer, _ <-chan struct{}, _ bool) error {
if len(tbc.labels) == 0 {
return errors.New("no external labels configured, uniquely identifying external labels must be configured; see https://thanos.io/tip/thanos/storage.md#external-labels for details.")
}
lset, err := parseFlagLabels(tbc.labels)
if err != nil {
return errors.Wrap(err, "unable to parse external labels")
}
if err := promclient.IsDirAccessible(tbc.path); err != nil {
return errors.Wrapf(err, "unable to access path '%s'", tbc.path)
}
confContentYaml, err := objStoreConfig.Content()
if err != nil {
return errors.Wrap(err, "unable to parse objstore config")
}
bkt, err := client.NewBucket(logger, confContentYaml, component.Upload.String(), nil)
if err != nil {
return errors.Wrap(err, "unable to create bucket")
}
bkt = objstoretracing.WrapWithTraces(objstore.WrapWithMetrics(bkt, extprom.WrapRegistererWithPrefix("thanos_", reg), bkt.Name()))
tbcDir, err := os.OpenRoot(tbc.path)
if err != nil {
runutil.CloseWithLogOnErr(logger, bkt, "bucket client")
return errors.Wrap(err, "unable to open tbc directory")View on GitHub (pinned to 35b8b99117)