Skip to content

Files copied to output directory with readonly attribute cause subsequent build/serve failure #1015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
snalexp opened this issue Aug 21, 2019 · 1 comment

Comments

@snalexp
Copy link

snalexp commented Aug 21, 2019

We store our book source in Perforce which typically causes files on the local drive to be read-only.

When we mdbook build, our images from the src/image directory end up marked as read-only in the book/img directory and subsequent builds will fail like this:

..\build\bin\mdbook.exe build
2019-08-21 08:05:41 [INFO] (mdbook::book): Book building has started
2019-08-21 08:05:41 [ERROR] (mdbook::utils): Error: Unable to clear output directory
2019-08-21 08:05:41 [ERROR] (mdbook::utils):    Caused By: Access is denied. (os error 5)

Would it be possible to copy the files and drop the RO attribute, or to be more forceful in cleaning the output directory.

The following steps should reproduce on Windows:

> mdbook init
Do you want a .gitignore to be created? (y/n)
n
What title would you like to give the book?
test

> mkdir src\img
> echo dummy > src\img\test.png
> attrib +R src\img\test.png
> mdbook build   <-- Success when book dir doesn't exist
> mdbook build   <-- Failure when book dir contains RO file
@tv42
Copy link

tv42 commented Feb 23, 2025

This also breaks building mdbook books under Nix (https://nixos.org/).
With Nix, the source tree is read-only. For some reason, additional-css files are copied twice (probably #1156), and the second copy fails with EACCESS because the first copy also set the access mode of the destination file to read-only.

openat(AT_FDCWD, "/nix/store/2i4mc95ndwgww8mpv0gj19hqnbynz9cb-crane-book/custom.css", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0100444) = 4
...
openat(AT_FDCWD, "/nix/store/2i4mc95ndwgww8mpv0gj19hqnbynz9cb-crane-book/custom.css", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0100444) = -1 EACCES (Permission denied)

(/nix/store/2i4mc95ndwgww8mpv0gj19hqnbynz9cb-crane-book is the destination path for the build, here)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants