### Bug description

I have the following in `_extensions/resources_example`:

```
.
├── _extension.yml
└── resources
    └── test_file.pdf
```

`_extension.yml`:

```yaml
title: Quarto issue 4377
author: Toni
version: 1.0.0
quarto-required: ">=1.2.0"
contributes:
  format:
    common:
      format-resources: 
        - resources/
    pdf:
      keep: false
```

When I render a document using this extension, this is what happens:

1. The first time, it works. The `resources` dir is copied to the root of the repository.
2. The second time it works.
3. The third time it does not work anymore due to a permission denied error.

The cause is that after the 2nd run, the `resources` dir becomes read-only and the 3d run can not remove the files anymore.

This is the trace:

```
ERROR: PermissionDenied: Permission denied (os error 13), remove '<...>/resources/test_file.pdf'

PermissionDenied: Permission denied (os error 13), remove '<...>/resources/test_file.pdf'
    at Object.removeSync (deno:runtime/js/30_fs.js:151:9)
    at copyFileSync (file:///Applications/quarto/bin/quarto.js:44975:14)
    at copyDirSync (file:///Applications/quarto/bin/quarto.js:45007:13)
    at copyTo (file:///Applications/quarto/bin/quarto.js:44920:9)
    at processFormatResources (file:///Applications/quarto/bin/quarto.js:68968:17)
    at async resourceDependenciesPostProcessor (file:///Applications/quarto/bin/quarto.js:69442:9)
    at async renderPandoc (file:///Applications/quarto/bin/quarto.js:69679:13)
    at async Object.onRender (file:///Applications/quarto/bin/quarto.js:79336:32)
    at async renderFiles (file:///Applications/quarto/bin/quarto.js:78709:21)
    at async render (file:///Applications/quarto/bin/quarto.js:79023:21)
```

This is on mac but it has been reproduced on Linux as well.


dragonstyle
2023-02-16T10:21:34Z
tverbeiren
bug
v1.3
closed
Using a directory in `format-resources` for extensions causes 'permission denied'
https://github.com/quarto-dev/quarto-cli/issues/4377