Skip to content

Saving pptx files fails if officer is installed read-only #706

@eline-anslot

Description

@eline-anslot

The issue #555 has been closed however the bug seems to still be present. I ran both commands from #555 (comment) and they both gave a permission error.

We came across this problem when running the following R code using officer version 0.6.10 and R version 4.5.1:

library(officer)

my_pres <- read_pptx() 
my_pres <- add_slide(my_pres, layout = "Title and Content", master = "Office Theme")
print(my_pres, target = file.path(tempdir(), "pptx_example'.pptx"))

which return the following error:

Error in write_xml.xml_document(private$doc, file = private$filename) : 
  Error closing file

You can use the following code to reproduce it:

nix-shell -p R -p rPackages.officer --run 'Rscript -e "library(officer); my_pres <- read_pptx(); my_pres <- add_slide(my_pres, layout = "Title and Content", master = "Office Theme"); print(my_pres, target = file.path(tempdir(), "pptx_example'.pptx"))"'

The information of the R session:

R version 4.5.1 (2025-06-13)
Platform: x86_64-pc-linux-gnu
Running under: NixOS 25.05 (Warbler)

Matrix products: default
BLAS/LAPACK: /nix/store/k8aawsx66xjgd8qhdr24dqaq9s0w8av5-blas-3/lib/libblas.so.3;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] officer_0.6.10

loaded via a namespace (and not attached):
 [1] compiler_4.5.1    R6_2.6.1          cli_3.6.5         ragg_1.4.0        tools_4.5.1       uuid_1.2-1        xml2_1.3.8        zip_2.3.3         textshaping_1.0.1
[10] lifecycle_1.0.4   rlang_1.1.6       systemfonts_1.2.3 openssl_2.3.3     askpass_1.2.1  

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions