Skip to content
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

LibreOffice installed, but check_libreoffice_export() reports FALSE #1

Open
njbart opened this issue Aug 26, 2022 · 5 comments
Open

Comments

@njbart
Copy link

njbart commented Aug 26, 2022

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
Copy link
Member

Weird

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

@njbart
Copy link
Author

njbart commented Aug 26, 2022


> locatexec::exec_available("libreoffice")
[1] TRUE
> 

@njbart
Copy link
Author

njbart commented Aug 26, 2022

BTW, doconv is version 0.1.4

@markheckmann
Copy link
Contributor

markheckmann commented Oct 3, 2024

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
Copy link
Contributor

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 

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

3 participants