45

Tried to do sudo apt-get update, get this response every time I run it:

Get:1 http://repo.radeon.com/rocm/apt/debian xenial InRelease [1814 B]
Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Err:1 http://repo.radeon.com/rocm/apt/debian xenial InRelease
  Couldn't create temporary file /tmp/apt.conf.RpjjUo for passing config to apt-key
Err:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Couldn't create temporary file /tmp/apt.conf.IvhgJr for passing config to apt-key
Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Err:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
  Couldn't create temporary file /tmp/apt.conf.F98B6M for passing config to apt-key
Get:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Err:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
  Couldn't create temporary file /tmp/apt.conf.WWtE1d for passing config to apt-key
Get:3 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
Err:3 http://archive.ubuntu.com/ubuntu bionic InRelease
  Couldn't create temporary file /tmp/apt.conf.TP8dgO for passing config to apt-key
Reading package lists... Done
W: GPG error: http://repo.radeon.com/rocm/apt/debian xenial InRelease: Couldn't create temporary file /tmp/apt.conf.RpjjUo for passing config to apt-key
E: The repository 'http://repo.radeon.com/rocm/apt/debian xenial InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://security.ubuntu.com/ubuntu bionic-security InRelease: Couldn't create temporary file /tmp/apt.conf.IvhgJr for passing config to apt-key
E: The repository 'http://security.ubuntu.com/ubuntu bionic-security InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://archive.ubuntu.com/ubuntu bionic-updates InRelease: Couldn't create temporary file /tmp/apt.conf.F98B6M for passing config to apt-key
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://archive.ubuntu.com/ubuntu bionic-backports InRelease: Couldn't create temporary file /tmp/apt.conf.WWtE1d for passing config to apt-key
E: The repository 'http://archive.ubuntu.com/ubuntu bionic-backports InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
W: GPG error: http://archive.ubuntu.com/ubuntu bionic InRelease: Couldn't create temporary file /tmp/apt.conf.TP8dgO for passing config to apt-key
E: The repository 'http://archive.ubuntu.com/ubuntu bionic InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Tried sudo apt-get clean, nothing happened. sudo apt-get upgrade states that there is nothing that needs to be upgraded. sudo apt-get check doesn't find anything either.

Using Ubuntu on Windows 10.

9 Answers9

91

You probably changed the file permissions on your /tmp folder, check with

ls -lad /tmp

The normal settings for /tmp are 1777, which ls shows as drwxrwxrwt. That is: wide open, except that only the owner of a file can remove it (that's what this extra t bit means for a directory).

If the settings are wrong, you can restore them with:

chmod 1777 /tmp

I would recommend rebooting the machine after making this change.

If you cannot reboot, check the answers here: https://unix.stackexchange.com/a/71625/20661

Another possibility would be that something is mounted to /tmp. Check with

mount | grep /tmp

NOTE: also check /var/tmp the same way, maybe you have the same error there

rubo77
  • 5,218
7

For me, I was using a Docker container and had mounted a directory to /tmp in the container, which was causing the conflict. I removed the mounted directory to /tmp and that allowed apt update to work.

wisbucky
  • 3,346
4

I saw this problem with docker. I had to remove a number of docker images and rebuild them. This happened after I changed docker's root dir.

Victor Pudeyev
  • 547
  • 1
  • 4
  • 7
3

I had this issue when building Docker images starting from Ubuntu images on an IBM Power9 machine.

When I started from the image ubuntu:focal with image ID 0a648e725100 I didn't have this problem. ls -ld /tmp (when run in the image) indeed shows permissions drwxrwxrwt, and the Dockerfile build instruction RUN apt-get update works (as does the rest, not shown).

However, there is another image called ppc64le/ubuntu:22.04, image ID 5c1fccf2a735 in which the permissions of /tmp, for whatever reason, were set to drwxr-xr-t and RUN apt-get update failed with the error message shown in the OP.

Adding RUN chmod 1777 /tmp to the Dockerfile solved the problem.

UPDATE : I encountered the same problem with the jupyter/datascience-notebook:hub-3.1.1 image, architecture X86_64, ID=f4ae5f5cf82a as well. This image is derived from an Ubuntu image. There must have been a /tmp permission problem in Ubuntu 22.04 itself which is not architecture- or image-dependent.

0

I got this error in VS Code dev container because I had a trailing \ in my Dockerfile. This can cause other issues like in here: https://github.com/microsoft/vscode-remote-release/issues/7319

oamandawi
  • 101
0

In my case the problem was my disk had errors.

ls -lad /tmp was fine, showing drwxrwxrwt, as explained in this answer.

So, it turns out I had to run fsck on the root dir.

Run df -h first to see what disks you have. Find the one mounted as your root disk at mount point /. Mine is /dev/mapper/sda4_crypt. So, I had to run this:

fsck /dev/mapper/sda4_crypt -y

...as explained by this answer.

I figured it out because I rebooted to see if that would help my sudo apt update error problem, and my system was unable to boot. It booted into the initramfs menu instead, as explained by the Q&A I linked to just above.

Then, after following those instructions and rebooting from the initramfs menu like this:

fsck /dev/mapper/sda4_crypt -y
reboot
exit

...then once logged back in, sudo apt update worked again!

Previously, it was showing various Couldn't create temporary file /tmp/apt.conf.RpjjUo for passing config to apt-key type errors as shown in this question.

Once sudo apt update worked again, I had to do this, as quoted from my answer here:

sudo apt update

sudo apt full-upgrade

...which told me to run sudo apt --fix-broken install, so I did that:

sudo apt --fix-broken install

Then, re-run the Software Updater GUI tool.

See also

  1. My comment here, where I refer back to this answer: https://askubuntu.com/questions/137655/boot-drops-to-a-initramfs-prompts-busybox/817660#comment2520181_817660
0

In my case for whatever reason I had a bunch of Folders in / that had the Immutable Flag set.

Check with

lsattr /

In my Case I was getting:

lsattr: Operation not supported While reading flags on /sys
--------------e------- /tools_rsync
---------------------- /run
lsattr: Operation not supported While reading flags on /vmlinuz.old
----i---------e------- /tmp
--------------e------- /mnt
lsattr: Operation not supported While reading flags on /initrd.img
--------------e------- /boot
--------------e------- /config.sh
lsattr: Operation not supported While reading flags on /initrd.img.old
----i---------e------- /root
-----------I--e------- /etc
lsattr: Operation not supported While reading flags on /lib
----i---------e------- /usr
lsattr: Operation not supported While reading flags on /vmlinuz
lsattr: Operation not supported While reading flags on /bin
lsattr: Operation not supported While reading flags on /proc
--------------e------- /media
--------------e------- /opt
--------------e------- /home
lsattr: Operation not supported While reading flags on /sbin
---------------------- /dev
--------------e------- /lost+found
----i---------e------- /var
lsattr: Operation not supported While reading flags on /lib64
----i---------e------- /srv

Fix the offending Folders with

chattr -i /tmp
0

In Docker I have added this command and it works:

RUN mkdir -p /tmp && chmod 1777 /tmp WORKDIR /app

Dave M
  • 13,250
Atul
  • 1
-1

I had the same error updating APT sources.

If you don't have anything to lose. Just empty the /tmp directory. I had thousands of directories from tomcat and although I had free space in /tmp partition a problem ocurred with that temporary file (/tmp/apt.conf.IqQJWO).

cd /tmp

rm -rf *

After this the update process worked correctly.