{"record":{"id":"5f28406ea24635b6","repo":"juicedata/juicefs","slug":"mount-point-s-cannot-be-an-existing-folder","errorCode":null,"errorMessage":"Mount point %s cannot be an existing folder","messagePattern":"Mount point (.+?) cannot be an existing folder","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/winfsp/winfs.go","lineNumber":1177,"sourceCode":"\t\toptions += \",FlushOnCleanup=1\"\n\t}\n\n\thost.SetCapCaseInsensitive(!caseSensitive)\n\thost.SetCapReaddirPlus(true)\n\n\tmountVolumeName := filepath.VolumeName(conf.Mountpoint)\n\tmountPointIsDrive := isDriveByVolumeName(conf.Mountpoint)\n\tif mountPointIsDrive {\n\t\tconf.Mountpoint = mountVolumeName\n\t}\n\n\tif !mountPointIsDrive && mountAsNetworkDrive {\n\t\treturn fmt.Errorf(\"Cannot mount to a local directory when --as-local-volume is not set\")\n\t}\n\n\tif !mountPointIsDrive {\n\t\tif _, err := os.Stat(conf.Mountpoint); err == nil {\n\t\t\treturn fmt.Errorf(\"Mount point %s cannot be an existing folder\", conf.Mountpoint)\n\t\t}\n\n\t\t// the parent directory of the mount point must exist\n\t\tparentDir := filepath.Dir(conf.Mountpoint)\n\t\tif _, err := os.Stat(parentDir); os.IsNotExist(err) {\n\t\t\treturn fmt.Errorf(\"Parent directory %s of mount point %s does not exist\", parentDir, conf.Mountpoint)\n\t\t}\n\t}\n\n\tlogger.Debugf(\"mount point: %s, mountPointIsDrive: %v, options: %s\", conf.Mountpoint, mountPointIsDrive, options)\n\texitOk := host.Mount(conf.Mountpoint, []string{\"-o\", options})\n\tif exitOk {\n\t\treturn nil\n\t}\n\n\treturn fmt.Errorf(\"juicefs mount command exit with error, please check the log for details\")\n}\n","sourceCodeStart":1159,"sourceCodeEnd":1195,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/pkg/winfsp/winfs.go#L1159-L1195","documentation":"For a non-drive mountpoint, the WinFsp layer requires the mount point path to NOT already exist — WinFsp creates it as a volume mount point itself. If os.Stat(conf.Mountpoint) succeeds (path exists), mounting is refused with this error.","triggerScenarios":"Mounting with --as-local-volume (or a non-drive path) where os.Stat(mountpoint) returns no error because the directory already exists on disk (e.g. pre-created with mkdir).","commonSituations":"Users pre-create the mount directory out of Linux habit before mounting; re-running a mount after an unclean previous teardown left the folder behind; provisioning tools (Ansible/Terraform) create the directory first.","solutions":["Remove or rename the existing directory before mounting: rmdir /s /q <path> (ensure it is empty).","Re-run the mount command; WinFsp will create the mount point.","If a stale folder remains from a crashed mount, clean it up after stopping the WinFsp service.","Adjust provisioning scripts to not pre-create the mountpoint for WinFsp mounts."],"exampleFix":"// shell\n# before\nmkdir C:\\jfs && juicefs mount sqlite3://test.db C:\\jfs --as-local-volume\n# after\njuicefs mount sqlite3://test.db C:\\jfs --as-local-volume","handlingStrategy":"validation","validationCode":"// PowerShell: ensure mountpoint does not pre-exist\n$mp = 'C:\\jfs'\nif (Test-Path $mp) { Remove-Item $mp -Force -Recurse -ErrorAction SilentlyContinue }","typeGuard":null,"tryCatchPattern":"if err := runMount(); err != nil && strings.Contains(err.Error(), \"cannot be an existing folder\") {\n    os.RemoveAll(mp) // after confirming it is safe/empty\n    err = runMount()\n}","preventionTips":["Never pre-create the WinFsp mount directory.","Provision parent directories only, not the leaf mountpoint.","Clean stale folders after unclean shutdowns.","Update Ansible/Terraform roles to skip mkdir for WinFsp targets."],"tags":["windows","winfsp","mount","filesystem"],"backgroundTag":"file-already-exists","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}