为什么即使运行“apt-file update”后,apt-file 仍报告“缓存为空”?

为什么即使运行“apt-file update”后,apt-file 仍报告“缓存为空”?

apt-file update有谁知道为什么 apt-file 即使运行后也会报告缓存为空apt update

[pop-os ~][I]% apt-file search /usr/lib/android-sdk/tools/bin/sdkmanager
E: The cache is empty. You need to run "apt update" first.
[pop-os ~][I]% apt-file update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
[pop-os ~][I]% sudo !!
sudo apt-file update
Hit:1 http://apt.pop-os.org/proprietary cosmic InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu cosmic InRelease          
Hit:3 http://us.archive.ubuntu.com/ubuntu cosmic-updates InRelease                           
Hit:4 http://ppa.launchpad.net/nextcloud-devs/client/ubuntu cosmic InRelease                 
Hit:5 http://us.archive.ubuntu.com/ubuntu cosmic-security InRelease      
Hit:6 http://repository.spotify.com stable InRelease                                         
Hit:7 http://us.archive.ubuntu.com/ubuntu cosmic-backports InRelease                         
Get:8 http://apt.pop-os.org/proprietary cosmic all Contents (deb) [102 kB]                   
Hit:9 http://ppa.launchpad.net/system76/pop/ubuntu cosmic InRelease                  
Get:10 http://us.archive.ubuntu.com/ubuntu cosmic amd64 Contents (deb) [40.9 MB]             
Get:11 http://apt.pop-os.org/proprietary cosmic i386 Contents (deb) [276 B]                  
Get:12 http://apt.pop-os.org/proprietary cosmic amd64 Contents (deb) [2,605 kB]              
Get:13 http://us.archive.ubuntu.com/ubuntu cosmic i386 Contents (deb) [40.2 MB]              
Get:14 http://us.archive.ubuntu.com/ubuntu cosmic-updates i386 Contents (deb) [5,178 kB]     
Get:15 http://us.archive.ubuntu.com/ubuntu cosmic-updates amd64 Contents (deb) [6,997 kB]    
Get:16 http://us.archive.ubuntu.com/ubuntu cosmic-security i386 Contents (deb) [3,784 kB]    
Get:17 http://us.archive.ubuntu.com/ubuntu cosmic-security amd64 Contents (deb) [5,296 kB]   
Get:18 http://us.archive.ubuntu.com/ubuntu cosmic-backports amd64 Contents (deb) [3,773 B]   
Get:19 http://us.archive.ubuntu.com/ubuntu cosmic-backports i386 Contents (deb) [3,772 B]    
Fetched 105 MB in 21s (4,952 kB/s)                                                           
Reading package lists... Done
Building dependency tree       
Reading state information... Done
148 packages can be upgraded. Run 'apt list --upgradable' to see them.
sudo -E apt-file update  20.30s user 1.16s system 95% cpu 22.585 total
[pop-os ~][I]% apt-file search /usr/lib/android-sdk/tools/bin/sdkmanager
E: The cache is empty. You need to run "apt update" first.
[pop-os ~][I]% apt update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
[pop-os ~][I]% sudo !!
sudo apt update
Hit:1 http://apt.pop-os.org/proprietary cosmic InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu cosmic InRelease                                   
Hit:3 http://us.archive.ubuntu.com/ubuntu cosmic-updates InRelease                           
Hit:4 http://us.archive.ubuntu.com/ubuntu cosmic-security InRelease                          
Hit:5 http://ppa.launchpad.net/nextcloud-devs/client/ubuntu cosmic InRelease                 
Hit:6 http://us.archive.ubuntu.com/ubuntu cosmic-backports InRelease     
Get:7 http://apt.pop-os.org/proprietary cosmic i386 Contents (deb) [276 B]                   
Hit:8 http://repository.spotify.com stable InRelease                                         
Get:9 http://apt.pop-os.org/proprietary cosmic all Contents (deb) [102 kB]                   
Hit:10 http://ppa.launchpad.net/system76/pop/ubuntu cosmic InRelease                 
Get:11 http://us.archive.ubuntu.com/ubuntu cosmic amd64 Contents (deb) [40.9 MB]       
Get:12 http://apt.pop-os.org/proprietary cosmic amd64 Contents (deb) [2,605 kB]              
Get:13 http://us.archive.ubuntu.com/ubuntu cosmic i386 Contents (deb) [40.2 MB]              
Get:14 http://us.archive.ubuntu.com/ubuntu cosmic-updates i386 Contents (deb) [5,178 kB]     
Get:15 http://us.archive.ubuntu.com/ubuntu cosmic-updates amd64 Contents (deb) [6,997 kB]    
Get:16 http://us.archive.ubuntu.com/ubuntu cosmic-security amd64 Contents (deb) [5,296 kB]   
Get:17 http://us.archive.ubuntu.com/ubuntu cosmic-security i386 Contents (deb) [3,784 kB]    
Get:18 http://us.archive.ubuntu.com/ubuntu cosmic-backports i386 Contents (deb) [3,772 B]    
Get:19 http://us.archive.ubuntu.com/ubuntu cosmic-backports amd64 Contents (deb) [3,773 B]   
Fetched 105 MB in 21s (4,963 kB/s)                                                           
Reading package lists... Done
Building dependency tree       
Reading state information... Done
148 packages can be upgraded. Run 'apt list --upgradable' to see them.
sudo -E apt update  20.24s user 1.15s system 95% cpu 22.470 total
[pop-os ~][I]% apt-file search /usr/lib/android-sdk/tools/bin/sdkmanager
E: The cache is empty. You need to run "apt update" first.
[pop-os ~][I]% sudo !!
sudo apt-file search /usr/lib/android-sdk/tools/bin/sdkmanager
E: The cache is empty. You need to run "apt update" first.

Distro 是 Pop!_OS(Ubuntu 的衍生版本),但我找不到 Pop!_OS 标签。

答案1

我能够通过清除/var/lib/apt/lists/然后再次更新 a​​pt 在 Pop!_OS 22.04 上修复此问题:

sudo rm -rf /var/lib/apt/lists/*_*
sudo apt-get update
apt-file search sdkmanager

我在这里找到了提示:https://unix.stackexchange.com/a/575356/243015

编辑:运行apt-get install <foo>apt-file 后再次退出工作。

答案2

不是原始问题的解决方案,但我没有足够的声誉来评论......

我也遇到了这个错误,作为替代方案,建议使用 Ubuntu 包搜索:https://packages.ubuntu.com/search?keywords=search

我认为搜索https://packages.ubuntu.com很好,但我想从终端执行此操作。因此,我编写了一个名为 的小型 Python CLI 应用程序apt-search,它执行搜索查询、解析 HTML 并提供良好的输出。

你可以在这里找到它:https://pypi.org/project/apt-search/

您可以使用pip/安装它pipx并像这样使用它

apt-search /usr/lib/android-sdk/tools/bin/sdkmanager
# No package found for file '/usr/lib/android-sdk/tools/bin/sdkmanager'!

apt-search sdkmanager
# sdkmanager: /usr/bin/sdkmanager
# sdkmanager: /usr/share/bash-completion/completions/sdkmanager

答案3

YMMV,以下为我解决了这样的问题。

你正在做:

sudo apt update
sudo apt-file update

但你却不见了

sudo apt-get update

来自(最近的OP)apt-file 手册页:

update:
此操作仅调用 apt update 或 apt-get update(取决于 tty 是否可用)。

与常规 apt update 或 apt-get update 直接相比,使用此方法的唯一优势是在您配置了 apt 文件特定配置(通过 Dir::Etc::apt-file-main 配置选项)的情况下。在这种情况下,将自动包含所述配置。

我觉得有一个错误,apt-file update它不调用apt-get update但实际上依赖于该数据库。

相关内容