{"record":{"id":"9a626896a9b1983f","repo":"microsoft/FASTER","slug":"cannot-use-localstoragedevice-from-non-windows-os-platform","errorCode":null,"errorMessage":"Cannot use LocalStorageDevice from non-Windows OS platform, use ManagedLocalStorageDevice instead.","messagePattern":"Cannot use LocalStorageDevice from non-Windows OS platform, use ManagedLocalStorageDevice instead\\.","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"error","filePath":"cs/src/core/Device/LocalStorageDevice.cs","lineNumber":107,"sourceCode":"        /// <param name=\"deleteOnClose\"></param>\n        /// <param name=\"disableFileBuffering\"></param>\n        /// <param name=\"capacity\">The maximum number of bytes this storage device can accommondate, or CAPACITY_UNSPECIFIED if there is no such limit </param>\n        /// <param name=\"recoverDevice\">Whether to recover device metadata from existing files</param>\n        /// <param name=\"initialLogFileHandles\">Optional set of preloaded safe file handles, which can speed up hydration of preexisting log file handles</param>\n        /// <param name=\"useIoCompletionPort\">Whether we use IO completion port with polling</param>\n        protected internal LocalStorageDevice(string filename,\n                                      bool preallocateFile = false,\n                                      bool deleteOnClose = false,\n                                      bool disableFileBuffering = true,\n                                      long capacity = Devices.CAPACITY_UNSPECIFIED,\n                                      bool recoverDevice = false,\n                                      IEnumerable<KeyValuePair<int, SafeFileHandle>> initialLogFileHandles = null,\n                                      bool useIoCompletionPort = true)\n                : base(filename, GetSectorSize(filename), capacity)\n        {\n            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))\n            {\n                throw new FasterException(\"Cannot use LocalStorageDevice from non-Windows OS platform, use ManagedLocalStorageDevice instead.\");\n            }\n\n            if (filename.Length > Native32.WIN32_MAX_PATH - 11)     // -11 to allow for \".<segment>\"\n                throw new FasterException($\"Path {filename} is too long\");\n\n            ThrottleLimit = 120;\n            this.useIoCompletionPort = useIoCompletionPort;\n            this._disposed = false;\n\n            if (useIoCompletionPort)\n            {\n                ThreadPool.GetMaxThreads(out int workerThreads, out _);\n                ioCompletionPort = Native32.CreateIoCompletionPort(new SafeFileHandle(new IntPtr(-1), false), IntPtr.Zero, UIntPtr.Zero, (uint)(workerThreads + NumCompletionThreads));\n                for (int i = 0; i < NumCompletionThreads; i++)\n                {\n                    var thread = new Thread(() => new LocalStorageDeviceCompletionWorker().Start(ioCompletionPort, _callback))\n                    {\n                        IsBackground = true","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/Device/LocalStorageDevice.cs#L89-L125","documentation":"LocalStorageDevice uses Windows-native APIs (IO completion ports, Native32 Win32 calls) and therefore only works on Windows. On Linux/macOS the constructor immediately throws, directing developers to ManagedLocalStorageDevice, which uses the cross-platform .NET file API.","triggerScenarios":"Calling new LocalStorageDevice(...) (or Devices.CreateLogDevice choosing it) on a non-Windows OS, detected via RuntimeInformation.IsOSPlatform(OSPlatform.Windows) == false.","commonSituations":"Deploying a Windows-developed FASTER application to Linux containers/Kubernetes without changing the device factory; CI running on Linux agents.","solutions":["Use Devices.CreateLogDevice(...), which on .NET (Core) selects ManagedLocalStorageDevice on non-Windows platforms.","Explicitly instantiate ManagedLocalStorageDevice for cross-platform local storage.","Guard device creation with RuntimeInformation checks if you must construct devices manually per OS."],"exampleFix":"// before\nvar device = new LocalStorageDevice(\"/data/store.log\");\n// after\nvar device = new ManagedLocalStorageDevice(\"/data/store.log\");","handlingStrategy":"validation","validationCode":"var device = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)\n    ? new LocalStorageDevice(path)\n    : new ManagedLocalStorageDevice(path);","typeGuard":"static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);","tryCatchPattern":null,"preventionTips":["Prefer Devices.CreateLogDevice factory over constructing device classes directly.","Test deployments on the target OS (Linux containers) in CI.","Use ManagedLocalStorageDevice by default for cross-platform builds."],"tags":["csharp","device","platform","windows","faster"],"backgroundTag":"unsupported-platform","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}