Can't convert an open Word with OneDrive, but can copy it
ZhuangQu opened this issue · 7 comments
When A.docx
is open, this happens:
> pandoc A.docx
pandoc.exe: A.docx: withBinaryFile: permission denied (Permission denied)
However, we can do this:
> copy A.docx B.docx
> pandoc B.docx
<p>It's OK.</p>
It's puzzling: if you can copy it, you should be able to convert it. Both require only read permission.
Does pandoc
need higher permissions than copy
? If so, I have a suggestion: Let pandoc
copy the target to a temp, convert the temp, and delete the temp. That would solve the issue perfectly.
Pandoc shouldn't need higher permissions than copy. Not sure what is going on here, because the error message is not very informative.
What are the permissions on A.docx? (I assume you're on Windows; I don't know anything about how permissions work on Windows.)
Have you tried changing the permissions to see if it makes a difference for pandoc?
My OS version is Windows 11 23H2 and pandoc version is 3.5. The permission of A.docx is default (unchanged since creation). I did more experiments and found that the issue occurred while OneDrive running. Would you consider my suggestion? This will make pandoc compatible with OneDrive.
I really can't help until the issue is more precisely diagnosed.
Is the file in question on a cloud drive?
I really can't help until the issue is more precisely diagnosed. Is the file in question on a cloud drive?
After reading your reply, I did another experiment and confirm your doubts. This issue requires three conditions:
(1) A.docx is open.
(2) OneDrive is running.
(3) A.docx is in the OneDrive folder.
I don't think I can help further, because I don't have a Windows/OneDrive setup to test on.
Are there other developers/contributors can help?
Pandoc shouldn't need higher permissions than copy.
I wonder if pandoc will lock the file when reading it?