Repository navigation
Description
Description
Saving a document opened from a SMB/UNC path (\\server\share\...) fails with EPERM.
MarkText successfully writes the atomic-save temp file, but the rename that replaces the
original file is rejected, so the edit is not persisted.
This is a regression in 0.20.0-rc.2. Confirmed A/B with the same file, machine and
preferences:
- rc.2 — 6 ×
EPERMbetween 15:56 and 17:00; every save on that file failed. - rc.1 — after downgrading, the file was edited and saved repeatedly with no error at
all (process started 17:11, last successful write 17:21).
Since rc.1 has no UNC branch in watcher.ts, the regression almost certainly comes from
#4778 — rc.2 makes usePolling unconditionally true for UNC paths, so
watcherUsePolling: false no longer has any effect:
// packages/desktop/src/main/filesystem/watcher.ts
const usePolling = isOsx || isUncPath(watchPath)
? true
: this._preferences.getItem<boolean>('watcherUsePolling')In rc.1 this was isOsx ? true : this._preferences.getItem('watcherUsePolling'), i.e. the
preference was honoured.
The PR description notes: "Real SMB / Windows network share verification was not performed
because no actual \\server\share environment was available."
Steps to Reproduce
- Share a directory over SMB (Samba on Ubuntu here), e.g.
\\192.168.0.15\share\docs. - Open a markdown file from that share in MarkText 0.20.0-rc.2.
- Edit it (auto-save on) or press Ctrl+S.
Expected Behavior
doc.md.<random> is renamed over doc.md with no error; the edit is saved.
Actual Behavior
[error] Error while saving: Error: EPERM: operation not permitted,
rename '\\192.168.0.15\share\docs\doc.md.1477937064'
-> '\\192.168.0.15\share\docs\doc.md'
The temp file is created fine — only the rename fails. Repeated saves keep failing.
Screenshots / Logs
%APPDATA%\marktext\logs\<pid>\main.log, 6 occurrences in one session:
15:56:25 [error] Error while saving: EPERM ... doc.md.4032362638 -> doc.md
15:57:07 [error] Error while saving: EPERM ... doc.md.2353257723 -> doc.md
16:00:29 [error] Error while saving: EPERM ... doc.md.3970241905 -> doc.md
16:04:32 [error] Error while saving: EPERM ... doc.md.885835634 -> doc.md
16:59:36 [error] Error while saving: EPERM ... doc.md.1477937064 -> doc.md
17:00:50 [error] Error while saving: EPERM ... doc.md.1516967782 -> doc.md
Ruled out:
- Only files on the UNC share are affected; local files save fine.
- Renaming a file over an existing file in the same share folder works from the same Windows
client (50/50 attempts succeeded) — the share is not read-only or broken. - No server-side process holds the file except during the save window.
- Resetting MarkText preferences to defaults did not help — consistent with the value
being overridden in code rather than read from preferences.
Operating System
Windows
MarkText Version
0.20.0-rc.2
OS Version
Windows 11 Pro (10.0.26200)
中文摘要
在 0.20.0-rc.2 上,保存从真实 SMB 共享(\\server\share\...)打开的文件会在原子保存的
rename 步骤报 EPERM:临时文件写入成功,但覆盖原文件被拒绝,编辑丢失。
已用同一文件、同一台机器、同一份配置做 A/B 确认:rc.2 在 15:56–17:00 间 6 次 EPERM、每次
保存都失败;降级到 rc.1 之后,同一文件反复编辑保存完全无报错(进程 17:11 启动,17:21
最后一次写入成功)。
rc.1 的 watcher.ts 里没有 UNC 分支,因此这个回归几乎可以确定来自 #4778 —— rc.2 对 UNC 路径
无条件强制 usePolling: true,使 watcherUsePolling: false 失效。该 PR 自述未在真实 SMB
共享上验证过。
已排除:共享本身可写(同目录 rename 覆盖压力测试 50/50 通过)、保存瞬间之外无进程占用该文件、
本地文件保存正常、恢复默认配置无效(该值被代码覆盖,配置层面改不动)。
🤖 Investigated with Claude Code
Activity
docs: correct what the rename refusal actually depends on (#5322)
fix(desktop): pick retry delays that land on a different phase (#5322)
fix(desktop): retry a save whose rename an SMB share refused (#5322) (#…