juicedata/juicefs · error
Failed to create bucket
Error message
Failed to create bucket %s: %s, previous error: %s Please create bucket %s manually, then format again.
What it means
The initial Put failed with a NoSuchBucket error, and the automatic bucket-creation attempt (store.Create) also failed. JuiceFS tried to create the missing bucket for you but could not, and it instructs you to create the bucket manually before formatting again.
Solutions
- Create the bucket manually with the provider CLI: `aws s3 mb s3://mybucket --region us-east-1`
- Correct the bucket name and endpoint in the --storage-url / format options
- Grant s3:CreateBucket permission if the bucket should be auto-created
- Verify the region: a bucket created in us-west-2 cannot be used via a us-east-1 endpoint in some providers
Example fix
// before juicefs format ... s3://mybucket // Failed to create bucket... // after aws s3 mb s3://mybucket --region us-east-1 juicefs format ... s3://mybucket
Defensive patterns
Strategy: validation
Validate before calling
// pre-check bucket existence // aws s3api head-bucket --bucket mybucket || aws s3 mb s3://mybucket
Type guard
func isNoSuchBucket(err error) bool {
return err != nil && strings.Contains(err.Error(), "NoSuchBucket")
} Try / catch
err := doTesting(ctx, store, key, data)
if err != nil && strings.Contains(err.Error(), "Please create bucket") {
// create bucket manually, then re-run format
} Prevention
- Create the bucket before running juicefs format
- Double-check bucket name spelling and region in the storage URL
- Grant s3:CreateBucket if auto-creation is desired
- Match the endpoint to the bucket's region
When it happens
Trigger: `juicefs format` with a bucket name/endpoint that doesn't exist, where the credentials also lack s3:CreateBucket permission, region is wrong (creation against wrong region endpoint), or the provider does not support auto-creation (e.g. some S3-compatible stores).
Common situations: Typo in bucket name; AWS account at a different region than the endpoint; IAM user with object permissions but not bucket-management permissions; OSS/COS endpoints mismatching the bucket region.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- delete failed
- Failed to create bucket
- Failed to get
- failed to get the first byte:, expect "h", but got
- Failed to put
AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06).
Data as JSON: /api/errors/272b03d6a6a29263.
Report an issue: GitHub.
Appendix: source
Thrown at cmd/format.go:341
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
func randSeq(n int) string {
b := make([]rune, n)
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := range b {
b[i] = letters[r.Intn(len(letters))]
}
return string(b)
}
func doTesting(ctx context.Context, store object.ObjectStorage, key string, data []byte) error {
if err := store.Put(ctx, key, bytes.NewReader(data)); err != nil {
if strings.Contains(strings.ToLower(err.Error()), "denied") {
return fmt.Errorf("Failed to put: %s", err)
}
if err2 := store.Create(ctx); err2 != nil {
if strings.Contains(err.Error(), "NoSuchBucket") {
return fmt.Errorf("Failed to create bucket %s: %s, previous error: %s\nPlease create bucket %s manually, then format again.",
store, err2, err, store)
} else {
return fmt.Errorf("Failed to create bucket %s: %s, previous error: %s",
store, err2, err)
}
}
if err := store.Put(ctx, key, bytes.NewReader(data)); err != nil {
return fmt.Errorf("Failed to put: %s", err)
}
}
// GLACIER storage class doesn't allow read after write
if _, ok := ctx.Value(object.TierKey{}).(uint8); ok {
return nil
}
p, err := store.Get(ctx, key, 0, -1)
if err != nil {
return fmt.Errorf("Failed to get: %s", err)
}View on GitHub (pinned to c9a67b23e8)