system call to soffice doesn't work from within RStudio

I'm using RStudio Version 1.3.1093 on a machine with Ubuntu 20.04. My R version is 4.0.3.

There's an unexpected behavior when I call this line of code from within RStudio:

system("soffice --headless --convert-to xlsx --outdir files/ files/EGP.xlsb")

It fails with the following messages:

/usr/lib/libreoffice/program/javaldx: error while loading shared libraries: libreglo.so: cannot open shared object file: No such file or directory
Warning: failed to read path from javaldx
/usr/lib/libreoffice/program/soffice.bin: error while loading shared libraries: libreglo.so: cannot open shared object file: No such file or directory
Warning message:
In system("soffice --headless --convert-to xlsx --outdir files/ files/EGP.xlsb") :
  error in running command

The error is exactly the same if I call the "naked" command from RStudio's terminal (soffice --headless --convert-to xlsx --outdir files/ files/EGP.xlsb):

user@machine:~/Right/Path/To/File$ soffice --headless --convert-to xlsx --outdir files/ files/EGP.xlsb
/usr/lib/libreoffice/program/javaldx: error while loading shared libraries: libreglo.so: cannot open shared object file: No such file or directory
Warning: failed to read path from javaldx
/usr/lib/libreoffice/program/soffice.bin: error while loading shared libraries: libreglo.so: cannot open shared object file: No such file or directory

However, if I do the same call from a terminal, it just works with no error and produces the expected output:

user@machine:~/Right/Path/To/File$ soffice --headless --convert-to xlsx --outdir files/ files/EGP.xlsb
convert /home/user/Right/Path/To/File/files/EGP.xlsb -> /home/user/Right/Path/To/File/files/EGP.xlsx using filter : Calc Office Open XML
Overwriting: /home/user/Right/Path/To/File/files/EGP.xlsx

I followed advice in this ask Ubuntu question, but the problem does not resolve.

Is RStudio missing the path to find libreoffice libraries, that somehow are clear for the system (as the terminal has no problems finding them)? How can I fix it?
Thanks!

Here is a related post that might help

https://codeyarns.com/tech/2019-09-05-libregloso-cannot-open-shared-object-file.html

PJ

Thanks PJ, but the askubuntu question is the one I cited in the question. The code Yarns one gives the same solution (updating LD_LIBRARY_PATH). The problem is it works when called from the terminal, but doesn't when I call it from a RStudio script.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.