6

Just installed LibreOffice 6.0.4.2 in Ubuntu 18.04.

LibreOffice can't open (nor list) files from /tmp directory.

I've read about AppArmor profiles, devs talking about the "expected" /home use case, etc., which I just consider another complete nonsense from the LibreOffice team.

I tried disabling AppArmor but LibreOffice wouldn't even open after that, so I re-enabled it.

Is there a solution so LibreOffice can access files in any folders in my system?

  • 1
    Is it a snap package? If so, see askubuntu.com/questions/1046585/… – DK Bose Jun 15 '18 at 14:40
  • 1
    @DKBose tks you're right. I installed it through Software Center initially, but removing it and adding again using apt solved the issue! – jfneis Jun 19 '18 at 18:13
  • ls -l /tmp? maybe permission issue? – Book Of Zeus Nov 6 '19 at 5:19
0

I did not have this problem with 18.04 and previous LibreOffice. But I'm having it now with Ubuntu 20.04 and LibreOffice 6.4.

After a bit of research I found out it is a permission problem. In Ubuntu 20.04, apps, including LibreOffice, do not have read access to the folder /tmp where applications (such as Firefox) put temporary files. By the way, you get the same problem if you try to open directly any file from web with its assigned application, directly in Firefox, without downloading it first (e.g. try to open in Firefox a web-stored .deb file with Software Installer).

One way to sort this is to download first the files and, only then, open them. But this is annoying.

Another way, it is to reassign the temporary directory in the /home/user/ directory. This has the advantage of lessening the space requirement on the / directory while still not compromising the security.

The temporary directory is governed by the TMPDIR environment setting. I used the solution proposed here by TrueDuality.

  1. Check where is your current temporary directory:
echo $TMPDIR

or

mktemp -u

It should something look like: /tmp/tmp.zrBHbp0Yt0

  1. Edit the file /etc/profile
sudo gedit /etc/profile
  1. Append the following code:
if [[ -O /home/$USER/tmp && -d /home/$USER/tmp ]]; then
        TMPDIR=/home/$USER/tmp
else
        # You may wish to remove this line, it is there in case
        # a user has put a file 'tmp' in there directory or a
        rm -rf /home/$USER/tmp 2> /dev/null
        mkdir -p /home/$USER/tmp
        TMPDIR=$(mktemp -d /home/$USER/tmp/XXXX)
fi

TMP=$TMPDIR
TEMP=$TMPDIR

export TMPDIR TMP TEMP
  1. reboot

  2. check if your temporary directory has been reassigned to your /home/user/ directory

echo $TMPDIR

This time, the return should be something like: /home/user/tmp/nrXo , showing that the temp directory has been reassigned.

Remarks:

  • at this point the problem should be solved and you should be able to do things such as open directly a file from Firefox (instead of downloading it first). The file will be opened in read-only mode.
  • ONLY IF the last step (5) confirms that the temp directory is now reassigned correctly, you can worry about the new /tmp file growing up endlessly. In order to correct this problem, we need to make sure that at the end of the session, the file is deleted. However, if the previous step was not completed properly, you log-in with root credentials and you proceed to the next step,this can create problems.

CAREFUL!

sudo gedit ~/.bash_logout

add the following lines:

if [ -O $TMPDIR && -d $TMPDIR ]; then
        rm -rf $TMPDIR/*
fi

save. close and reboot.

| improve this answer | |
  • Did you try @DKBose solution of installing it through apt? – jfneis May 1 at 16:47
  • yes. my libre office was installed through apt. In fact this is not the problem. The problem is the permission rights of the folder /tmp . – RazTaz May 4 at 9:16
  • in fact, it's very easy to test: try find an .mp3 file over web. In Firefox, instead of "save", use "open with.." and chose your favourite app to open. If it's not working it's a /tmp read permission problem. As I wrote in my post, I had the same problem when I tried to install a .deb file from the web: it would not work unless I downloaded it first. – RazTaz May 4 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.