4

I have set up Ubuntu 21.04 Base image in Termux. When I run apt update, I get the following error. As I was not able to run apt update, I cannot install any packages.

root@localhost:~# apt update
Get:1 http://ports.ubuntu.com/ubuntu-ports hirsute InRelease [269 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports hirsute-updates InRelease [109 kB]
Get:3 http://ports.ubuntu.com/ubuntu-ports hirsute-backports InRelease [90.7 kB]
Get:4 http://ports.ubuntu.com/ubuntu-ports hirsute-security InRelease [101 kB]
Reading package lists... Done
E: Unable to determine file size for fd 7 - fstat (1: Operation not permitted)
E: The repository 'http://ports.ubuntu.com/ubuntu-ports hirsute InRelease' provides only weak security information.
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.
E: Unable to determine file size for fd 7 - fstat (1: Operation not permitted)
E: The repository 'http://ports.ubuntu.com/ubuntu-ports hirsute-updates InRelease' provides only weak security information.
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.
E: Unable to determine file size for fd 7 - fstat (1: Operation not permitted)
E: The repository 'http://ports.ubuntu.com/ubuntu-ports hirsute-backports InRelease' provides only weak security information.
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.
E: Unable to determine file size for fd 7 - fstat (1: Operation not permitted)
E: The repository 'http://ports.ubuntu.com/ubuntu-ports hirsute-security InRelease' provides only weak security information.
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.

How to fix this? This error is absent in the 20.04.2 base image.

Here is the output for permissions of /tmp.

root@localhost:~# ls -ld /tmp
drwx------ 2 root root 3488 Jul  1 10:54 /tmp

Here is the sources.list (I have not modified it).

root@localhost:~# cat /etc/apt/sources.list
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://ports.ubuntu.com/ubuntu-ports/ hirsute main restricted
# deb-src http://ports.ubuntu.com/ubuntu-ports/ hirsute main restricted

Major bug fix updates produced after the final release of the

distribution.

deb http://ports.ubuntu.com/ubuntu-ports/ hirsute-updates main restricted

deb-src http://ports.ubuntu.com/ubuntu-ports/ hirsute-updates main restricted

N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu

team. Also, please note that software in universe WILL NOT receive any

review or updates from the Ubuntu security team.

deb http://ports.ubuntu.com/ubuntu-ports/ hirsute universe

deb-src http://ports.ubuntu.com/ubuntu-ports/ hirsute universe

deb http://ports.ubuntu.com/ubuntu-ports/ hirsute-updates universe

deb-src http://ports.ubuntu.com/ubuntu-ports/ hirsute-updates universe

N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu

team, and may not be under a free licence. Please satisfy yourself as to

your rights to use the software. Also, please note that software in

multiverse WILL NOT receive any review or updates from the Ubuntu

security team.

deb http://ports.ubuntu.com/ubuntu-ports/ hirsute multiverse

deb-src http://ports.ubuntu.com/ubuntu-ports/ hirsute multiverse

deb http://ports.ubuntu.com/ubuntu-ports/ hirsute-updates multiverse

deb-src http://ports.ubuntu.com/ubuntu-ports/ hirsute-updates multiverse

N.B. software from this repository may not have been tested as

extensively as that contained in the main release, although it includes

newer versions of some applications which may provide useful features.

Also, please note that software in backports WILL NOT receive any review

or updates from the Ubuntu security team.

deb http://ports.ubuntu.com/ubuntu-ports/ hirsute-backports main restricted universe multiverse

deb-src http://ports.ubuntu.com/ubuntu-ports/ hirsute-backports main restricted universe multiverse

Uncomment the following two lines to add software from Canonical's

'partner' repository.

This software is not part of Ubuntu, but is offered by Canonical and the

respective vendors as a service to Ubuntu users.

deb http://archive.canonical.com/ubuntu hirsute partner

deb-src http://archive.canonical.com/ubuntu hirsute partner

deb http://ports.ubuntu.com/ubuntu-ports/ hirsute-security main restricted

deb-src http://ports.ubuntu.com/ubuntu-ports/ hirsute-security main restricted

deb http://ports.ubuntu.com/ubuntu-ports/ hirsute-security universe

deb-src http://ports.ubuntu.com/ubuntu-ports/ hirsute-security universe

deb http://ports.ubuntu.com/ubuntu-ports/ hirsute-security multiverse

deb-src http://ports.ubuntu.com/ubuntu-ports/ hirsute-security multiverse

Archisman Panigrahi
  • 28,338
  • 18
  • 105
  • 212
  • What permissions for /tmp ? – jasmines Jul 01 '21 at 08:13
  • @jasmines Could you clarify your comment? – Archisman Panigrahi Jul 01 '21 at 08:35
  • nothing to be clarified, jut post output for the following command: ls -ld /tmp/ – jasmines Jul 01 '21 at 09:15
  • please check your 'sources.list'. try this one 'https://askubuntu.com/a/1340401/856659' – abu-ahmed al-khatiri Jul 01 '21 at 11:39
  • @abu-ahmedal-khatiri I am using the default sources.list which uses ports.ubuntu.com (I have added it to my question). I don't know if other mirrors work for ARM. – Archisman Panigrahi Jul 01 '21 at 12:10
  • @ArchismanPanigrahi the note said '## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu team. Also, please note that software in universe WILL NOT receive any review or updates from the Ubuntu security team.'. you can try to change the repo 'http://us.archive.canonical.com/ubuntu hirsute' , and change 'US' to based your country. Make sure that Image is compatible with your Hardware. – abu-ahmed al-khatiri Jul 01 '21 at 12:28
  • @abu-ahmedal-khatiri Universe and multiverse were never supported by Canonical. They are community supported. ports.ubuntu.com is the standard repository for ARM (They are also there in the official Raspberry Pi images, for example). But I will try the US mirror. – Archisman Panigrahi Jul 01 '21 at 13:03
  • @abu-ahmedal-khatiri The same issue is present even after switching to the sources.list in https://askubuntu.com/a/1340401/856659 (i.e. the US mirror). – Archisman Panigrahi Jul 01 '21 at 13:15

3 Answers3

0

Correct permissions:

sudo chmod 777 -R /tmp
jasmines
  • 11,011
  • The same issue is still present – Archisman Panigrahi Jul 01 '21 at 13:06
  • Ok, let's go more verbose:

    sudo apt -oDebug::pkgAcquire::Worker=1 update

    – jasmines Jul 01 '21 at 13:42
  • Here it is. https://paste.ubuntu.com/p/XfxSNWqQ4m/ – Archisman Panigrahi Jul 01 '21 at 14:04
  • The problem is definitely on repo side. You can't do anything on client side, but you could try to contact the repo maintainers. Or, better, find alternatives. Check here: https://askubuntu.com/questions/428698/are-there-alternative-repositories-to-ports-ubuntu-com-for-arm – jasmines Jul 01 '21 at 14:38
  • Thanks @ArchismanPanigrahi . I have updated my answer to point to the documentation page were they explain about apt limitations and also about where are the official repos. If you upgraded you may want to install clean. Cheers – Carles Mateo Jul 05 '21 at 11:50
0

Please, locate the PID for apt update with:

ps ax | grep "apt"

When you know type:

ls -al /proc/PID/fd/

Where PID is the process number you obtained before.

What is the File Descriptor named 7?.

Update 2021-07-05:

May be it is normal.

According to Termux documentation https://wiki.termux.com/wiki/Package_Management :

Apt usage under root is restricted to prevent messing up ownership and SELinux labels on Android /data partition.

We strongly recommend to use a pkg utility instead of apt directly...

Downgrading is not supported. In order to reclaim disk space, we do not keep history of package versions.

Carles Mateo
  • 1,577
  • 6
  • 12
  • Does not work. Error: /proc must be mounted To mount /proc at boot you need an /etc/fstab line like: proc /proc proc defaults In the meantime, run "mount proc /proc -t proc" However, apt works successfully in 20.04 image. – Archisman Panigrahi Jul 05 '21 at 06:25
  • When I try to mount, I get root@localhost:~# mount proc /proc -t proc mount: /proc: mount(2) system call failed: Function not implemented. – Archisman Panigrahi Jul 05 '21 at 06:26
  • Hi @ArchismanPanigrahi /proc should be mounted by default in your Linux. Can you output the results of ls -al / Thanks – Carles Mateo Jul 05 '21 at 09:37
  • https://paste.ubuntu.com/p/63d6dVfBnn/ Here it is. /proc is not mounted most likely because it is a limitation of running inside Android. Note that the same error message for proc is shown in Ubuntu 20.04 image, but there apt works perfectly. – Archisman Panigrahi Jul 05 '21 at 10:49
  • 1
    Apt usage under root is restricted to prevent messing up ownership and SELinux labels on Android /data partition. That is about directly running apt in Termux, not apt in Ubuntu image running inside Termux (note that apt works fine with the Ubuntu 20.04 image). – Archisman Panigrahi Jul 05 '21 at 12:21
0

[As of 1st dec, 2021]

For me it was due to mounting to /tmp path with ubuntu 20.04. I had to change mount location to /usr/local/bin

Check here and here.

Koder101
  • 101