{"record":{"id":"ab3abea7d2f63519","repo":"dgraph-io/badger","slug":"errwindowsnotsupported","errorCode":"ErrWindowsNotSupported","errorMessage":"Read-only mode is not supported on Windows","messagePattern":"Read-only mode is not supported on Windows","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":82,"sourceCode":"\n\t// ErrManagedTxn is returned if the user tries to use an API which isn't\n\t// allowed due to external management of transactions, when using ManagedDB.\n\tErrManagedTxn = stderrors.New(\n\t\t\"Invalid API request. Not allowed to perform this action using ManagedDB\")\n\n\t// ErrNamespaceMode is returned if the user tries to use an API which is allowed only when\n\t// NamespaceOffset is non-negative.\n\tErrNamespaceMode = stderrors.New(\n\t\t\"Invalid API request. Not allowed to perform this action when NamespaceMode is not set.\")\n\n\t// ErrInvalidDump if a data dump made previously cannot be loaded into the database.\n\tErrInvalidDump = stderrors.New(\"Data dump cannot be read\")\n\n\t// ErrZeroBandwidth is returned if the user passes in zero bandwidth for sequence.\n\tErrZeroBandwidth = stderrors.New(\"Bandwidth must be greater than zero\")\n\n\t// ErrWindowsNotSupported is returned when opt.ReadOnly is used on Windows\n\tErrWindowsNotSupported = stderrors.New(\"Read-only mode is not supported on Windows\")\n\n\t// ErrPlan9NotSupported is returned when opt.ReadOnly is used on Plan 9\n\tErrPlan9NotSupported = stderrors.New(\"Read-only mode is not supported on Plan 9\")\n\n\t// ErrTruncateNeeded is returned when the value log gets corrupt, and requires truncation of\n\t// corrupt data to allow Badger to run properly.\n\tErrTruncateNeeded = stderrors.New(\n\t\t\"Log truncate required to run DB. This might result in data loss\")\n\n\t// ErrBlockedWrites is returned if the user called DropAll. During the process of dropping all\n\t// data from Badger, we stop accepting new writes, by returning this error.\n\tErrBlockedWrites = stderrors.New(\"Writes are blocked, possibly due to DropAll or Close\")\n\n\t// ErrNilCallback is returned when subscriber's callback is nil.\n\tErrNilCallback = stderrors.New(\"Callback cannot be nil\")\n\n\t// ErrEncryptionKeyMismatch is returned when the storage key is not\n\t// matched with the key previously given.","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/dgraph-io/badger/blob/2a001d466f6b71a917319a1db41f99860e16e269/errors.go#L64-L100","documentation":"ErrWindowsNotSupported is returned when opt.ReadOnly is used on Windows, where read-only mode is not implemented. It surfaces from acquireDirectoryLock (dir_windows.go:62) during DB.Open, and some tests special-case it. Defined in errors.go.","triggerScenarios":"Opening a DB with badger.WithReadOnly(true) on a Windows host; the check fires immediately in acquireDirectoryLock during Open.","commonSituations":"Cross-platform applications using ReadOnly on a dev machine running Windows; CI matrix including Windows; running a read-replica deployment on Windows hosts.","solutions":["Disable ReadOnly on Windows and open the DB read-write","Move read-only workloads to Linux/Plan9-free environments","Gate the WithReadOnly option behind a runtime.GOOS check in your config code"],"exampleFix":"// before\nopts = append(opts, badger.WithReadOnly(true))\ndb, err := badger.Open(opts...)\n// after\nif runtime.GOOS != \"windows\" {\n\topts = append(opts, badger.WithReadOnly(true))\n}\ndb, err := badger.Open(opts...)","handlingStrategy":"validation","validationCode":"if readOnly && runtime.GOOS == \"windows\" { return errors.New(\"ReadOnly unsupported on Windows\") }","typeGuard":null,"tryCatchPattern":"db, err := badger.Open(opts)\nif errors.Is(err, ErrWindowsNotSupported) {\n\t// fall back to read-write mode or fail fast on Windows\n}","preventionTips":["Gate WithReadOnly on runtime.GOOS in config code","Test the full option matrix in CI including Windows","Keep read-only replicas on supported platforms (Linux)"],"tags":["badger","windows","read-only","platform-limitation"],"backgroundTag":"platform-not-supported","analyzedSha":"2a001d466f6b71a917319a1db41f99860e16e269","analyzedAt":"2026-09-05T13:00:02.264Z","contentChangedAt":"2026-09-05T13:00:02.264Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}