运行 apt update 时出错 E: 无法确定 fd 7 的文件大小 - fstat

运行 apt update 时出错 E: 无法确定 fd 7 的文件大小 - fstat

我已经设置了 Ubuntu 21.04基础映像在 Termux 中。当我运行 时apt update,出现以下错误。由于无法运行apt update,因此无法安装任何软件包。

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.

如何修复?20.04.2 基础映像中不存在此错误。

以下是 的权限的输出/tmp

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

这是sources.list(我有不是对其进行了修改)。

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

答案1

正确的权限:

sudo chmod 777 -R /tmp

答案2

请使用以下命令找到 apt update 的 PID:

ps ax | grep "apt"

当您知道类型时:

ls -al /proc/PID/fd/

其中PID是您之前获得的进程号。

名为 7 的文件描述符是什么?

更新 2021-07-05:

或许这是正常的。

根据 Termux 文档https://wiki.termux.com/wiki/Package_Management

限制在 root 下使用 Apt,以防止混淆 Android /data 分区上的所有权和 SELinux 标签。

我们强烈建议使用 pkg 实用程序,而不是直接使用 apt...

不支持降级。为了回收磁盘空间,我们不保留软件包版本的历史记录。

答案3

[截至 2021 年 12 月 1 日]

对我来说,这是由于/tmp使用 ubuntu 20.04 安装到路径。我不得不将安装位置更改为/usr/local/bin

查看这里这里

相关内容