ardata-fr / doconv

Other
15 stars 2 forks source link

LibreOffice installed, but check_libreoffice_export() reports FALSE #1

Open njbart opened 2 years ago

njbart commented 2 years ago

My LibreOffice installation works as expected throughout, both when using the GUI as well as in “headless” mode.

check_libreoffice_export(), however, reports FALSE, both in the R command line interface and in RStudio.

Are there any additional diagnostics available from check_libreoffice_export(), or any other suggestions what to try next?

> library(doconv)
> check_libreoffice_export()
[1] FALSE
> 

macOS 11.6.8 LibreOffice 7.4.0.3, installed via homebrew R version 4.2.1 RStudio 2022.07.1 Build 554

davidgohel commented 2 years ago

Weird

what does locatexec::exec_available("libreoffice") returns?

njbart commented 2 years ago

> locatexec::exec_available("libreoffice")
[1] TRUE
> 
njbart commented 2 years ago

BTW, doconv is version 0.1.4

markheckmann commented 1 month ago

Same for me on Windows 11, I did not encounter the problem on MacOS.

# on Windows

library(doconv)

check_libreoffice_export()
#> [1] FALSE

locatexec::exec_available("libreoffice")
#> [1] TRUE
processx::run(locatexec::libreoffice_exec(), "--version")
#> $status
#> [1] 0
#> 
#> $stdout
#> [1] "LibreOffice 24.8.0.3 0bdf1299c94fe897b119f97f3c613e9dca6be583\r\n\r\n"
#> 
#> $stderr
#> [1] ""
#> 
#> $timeout
#> [1] FALSE

sessionInfo()
#> R version 4.4.1 (2024-06-14 ucrt)
#> Platform: x86_64-w64-mingw32/x64
#> Running under: Windows 11 x64 (build 22621)
#> 
#> Matrix products: default
#> 
#> 
#> locale:
#> [1] LC_COLLATE=German_Germany.utf8  LC_CTYPE=German_Germany.utf8   
#> [3] LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C                   
#> [5] LC_TIME=German_Germany.utf8    
#> 
#> time zone: Europe/Berlin
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] doconv_0.3.2
#> 
#> loaded via a namespace (and not attached):
#>  [1] digest_0.6.37     R6_2.5.1          qpdf_1.3.3        fastmap_1.2.0    
#>  [5] xfun_0.47         magrittr_2.0.3    locatexec_0.1.1   glue_1.7.0       
#>  [9] knitr_1.48        htmltools_0.5.8.1 rmarkdown_2.28    lifecycle_1.0.4  
#> [13] ps_1.7.7          cli_3.6.3         processx_3.8.4    askpass_1.2.0    
#> [17] reprex_2.1.1      withr_3.0.1       compiler_4.4.1    rstudioapi_0.16.0
#> [21] tools_4.4.1       evaluate_0.24.0   Rcpp_1.0.13       magick_2.8.4     
#> [25] yaml_2.3.10       pdftools_3.4.0    rlang_1.1.4       fs_1.6.4

Created on 2024-10-03 with reprex v2.1.1

markheckmann commented 1 month ago

Debugging

Settings run(echo=TRUE) in check_libreoffice_export() I get the following error:

> check_libreoffice_export()
Running "C:/Program Files/LibreOffice/program/soffice.com" --headless \
  "-env:UserInstallation=file:///C:/Users/heckm/AppData/Local/Temp/RtmpkHCdKd/lo_7180253e3216" \
  --convert-to "pdf:writer_pdf_Export" --outdir \
  "C:\Users\heckm\AppData\Local\Temp\RtmpkHCdKd\file718069c7d22"  \
  "C:\Users\heckm\AppData\Local\Temp\RtmpkHCdKd\file718069c7d22/minimal-word.docx"
Entity: line 1: parser error : Document is empty

^
[1] FALSE

Interestingly, the error also occurs when pasting the command in the Command Prompt. But then after a appr. 20 seconds (!), the process finishes and produces the file. The second time, the whole process runs much faster and correctly overwrites the file.

error

Quick Fix

I suspect, that this is an Libre Office issue. Not sure if this can be fixed on the R side. A quick "solution" in R would be to increase the timeout. With run(timeout = 45, echo=TRUE) I get:

> check_libreoffice_export()
Running "C:/Program Files/LibreOffice/program/soffice.com" --headless \
  "-env:UserInstallation=file:///C:/Users/heckm/AppData/Local/Temp/RtmpkHCdKd/lo_718039b5ba1" \
  --convert-to "pdf:writer_pdf_Export" --outdir \
  "C:\Users\heckm\AppData\Local\Temp\RtmpkHCdKd\file71803e887c6" \
  "C:\Users\heckm\AppData\Local\Temp\RtmpkHCdKd\file71803e887c6/minimal-word.docx"
Entity: line 1: parser error : Document is empty

^
convert C:\Users\heckm\AppData\Local\Temp\RtmpkHCdKd\file71803e887c6\minimal-word.docx as a Writer document -> C:\Users\heckm\AppData\Local\Temp\RtmpkHCdKd\file71803e887c6\minimal-word.pdf using filter : writer_pdf_Export
[1] TRUE