juicedata/juicefs · error

failed to load config: %s

Error message

failed to load config: %s

What it means

newMinio builds an AWS SDK v2 config via config.LoadDefaultConfig, supplying static credentials when accessKey is set. If config loading itself fails (malformed shared config/credentials files, invalid profile, invalid SDK env values), the constructor returns this wrapped error.

Source

Thrown at pkg/object/minio.go:91

	}
	if region == "" {
		region = awsDefaultRegion
	}
	if accessKey == "" {
		accessKey = os.Getenv("MINIO_ACCESS_KEY")
	}
	if secretKey == "" {
		secretKey = os.Getenv("MINIO_SECRET_KEY")
	}
	var cfg aws.Config
	if accessKey != "" {
		cfg, err = config.LoadDefaultConfig(ctx, append(defaultChecksumOpts(),
			config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider(accessKey, secretKey, token)))...)
	} else {
		cfg, err = config.LoadDefaultConfig(ctx, defaultChecksumOpts()...)
	}
	if err != nil {
		return nil, fmt.Errorf("failed to load config: %s", err)
	}
	client := s3.NewFromConfig(cfg, func(options *s3.Options) {
		options.Region = region
		options.BaseEndpoint = aws.String(uri.Scheme + "://" + uri.Host)
		options.EndpointOptions.DisableHTTPS = !ssl
		options.UsePathStyle = defaultPathStyle()
		options.HTTPClient = httpClient
		options.APIOptions = append(options.APIOptions, func(stack *smithymiddleware.Stack) error {
			return v4.SwapComputePayloadSHA256ForUnsignedPayloadMiddleware(stack)
		}, addS3UserAgent)
		options.RetryMaxAttempts = 1
	})
	if len(uri.Path) < 2 {
		return nil, fmt.Errorf("no bucket name provided in %s", endpoint)
	}
	bucket := uri.Path[1:]
	if strings.Contains(bucket, "/") && strings.HasPrefix(bucket, "minio/") {
		bucket = bucket[len("minio/"):]

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Read the wrapped error's underlying cause and fix the offending config/credentials file or env variable.
  2. Set AWS_PROFILE/AWS_CONFIG_FILE explicitly, or unset them to use defaults.
  3. Verify ~/.aws/config and ~/.aws/credentials parse correctly (e.g. with 'aws configure list').
Defensive patterns

Strategy: try-catch

Validate before calling

if os.Getenv("AWS_CONFIG_FILE") != "" {
	if _, err := os.Stat(os.Getenv("AWS_CONFIG_FILE")); err != nil {
		return fmt.Errorf("AWS_CONFIG_FILE missing: %w", err)
	}
}

Try / catch

store, err := newMinio(endpoint, ak, sk, "")
if err != nil && strings.Contains(err.Error(), "failed to load config") {
	// inspect ~/.aws files and SDK env vars, then retry
	return err
}

Prevention

When it happens

Trigger: AWS SDK config initialization failing due to malformed ~/.aws/config or ~/.aws/credentials, a broken profile referenced by AWS_PROFILE, or invalid values for SDK environment variables.

Common situations: Corrupted or hand-edited AWS shared config files on the machine running JuiceFS; AWS_CONFIG_FILE pointing to a missing/invalid file; files written by older tooling that the current SDK rejects.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/c13ed18dd16466e5. Report an issue: GitHub.