修复 Arch Linux 中的 “target not found” 错误
软件包
![](/data/attachment/album/202311/26/235547szhfv062quxx0hry.png)



> 
> 如果在 Arch Linux 中安装软件包时遇到 “target not found” 错误，你可以采取以下措施。
> 
> 
> 


有一天，我尝试在 Arch Linux 上安装 Hyprland。当我使用 [Pacman 命令安装](https://itsfoss.com/pacman-command/) 它时，它抛出 “target not found”（目标未发现）错误。



```
$ sudo pacman -S hyprland
[sudo] password for abhishek:
error: target not found: hyprland


```

这是一个意外，因为我知道 Hyprland 是可用的。


**我的修复方法**是更新系统，在大多数情况下，它可以解决此问题。



```
sudo pacman -Syu

```

这里，本地包数据库不同步。我需要更新缓存。这里还建议更新系统。


在大多数情况下，这就是修复此错误的方法。但是，你看到此错误的原因可能还有其他一些。让我在这里详细讨论它们。


### 修复：更新系统


Arch Linux 是一个 [滚动发布发行版](https://itsfoss.com/rolling-release/)，并且它提供的更新非常频繁。如果你不每隔几天更新一次系统，你的本地包数据库将与远程镜像不同步，并且你将在安装软件包时遇到问题。


本地包数据库仅保留包的元数据，例如版本号、用于获取包的仓库 URL 等。


当你搜索软件包时，`pacman` 会提供搜索结果，表明该软件包可用。但是，该包在你的本地数据库中具有较旧的版本号。当 `pacman` 在远程仓库中搜索包（以获取实际的包）时，它不再找到旧版本的 URL。


这就是导致 “target not found” 错误的原因。


修复方法是更新本地数据库。这可以与 `pacman -Sy` 一起使用，但是，建议 [更新整个 Arch Linux 系统](https://itsfoss.com/update-arch-linux/) 以避免依赖冲突等。



```
sudo pacman -Syu

```


> 
> ? 如果你已有几周没有更新系统，请做好更新超过 1 GB 的准备。这可能需要一些时间，具体取决于你的互联网速度和你使用的镜像。
> 
> 
> 


就我而言，Arch 安装在我的辅助系统上。由于我一周左右无法使用它，该系统已经过时了。更新后，我就可以安装 [Hyprland](https://hyprland.org/)。


![](/data/attachment/album/202311/26/235445jk24ct2kni44cicc.png)



> 
> ? 如果这不起作用，请通过添加额外的 `y` 强制刷新所有包数据库： `sudo pacman -Syyu`
> 
> 
> 


### 修复 “target not found” 错误的其他建议


如果上述方法没有为你解决此错误，这里有一些修复此错误的提示。


#### 仔细检查包名称


我亲爱的 Watson，这可能看起来很简单，但人们通常只是错误地输入了包名称。


Linux 区分大小写，包通常以小写命名。因此，如果你要使用一个名为 Flameshot 的流行工具，那么它的包名称很可能是 flameshot。


此外，某些软件的拼写与常见软件的拼写不同。例如，它是 hyprland，这使我错误地输入了 hyperland（使用通常的 “hyper” 拼写）。


![](/data/attachment/album/202311/26/235446my8zqekkqqctyqpc.png)


在极少数情况下，可能会混淆是 `l`、`I` 或者 `1`。


基本上，确保你输入的包名称是正确的。


#### 查看该软件包在仓库中是否可用


Arch Linux 的仓库中有大量软件包。但这并不意味着它拥有所有可能的 Linux 软件包。


访问 Arch Linux 官方软件包网站：


[Arch Linux 软件包搜索](https://archlinux.org/packages/)


在这里输入包名，查看该包是否可用。如果是，它是哪个仓库以及它在哪个设备上可用。


![](/data/attachment/album/202311/26/235446eswqtcest8g7qstt.png)


`x86_64` 适用于英特尔架构，任何包含 ARM 架构的均适用于 [树莓派类设备](https://itsfoss.com/raspberry-pi-alternatives/)。



> 
> ? 如果在某些仓库中找到该软件包，但 pacman 即使在更新的系统上也找不到它，请检查 `pacman.conf` 文件并查看是否启用了所述仓库。
> 
> 
> 


#### 确保它不是 AUR 包


[Arch 用户仓库（AUR）](https://itsfoss.com/aur-arch-linux/) 是提供更新包的附加社区支持平台。


现在，有多种使用 AUR 包的方法，但 `pacman` 不是其中之一。


检查你尝试安装的软件包是否是 AUR 软件包。首先检查官方 Arch 仓库，如上所述。如果不存在，请检查 AUR 页面。


如果它是 AUR 包，则必须 [使用 yay](https://itsfoss.com/install-yay-arch-linux/) 或一些 [其他 AUR 帮助程序](https://itsfoss.com/best-aur-helpers/)。你不能使用 `pacman` 安装 AUR 软件包。


### 你能解决这个问题吗？


在大多数情况下，更新系统可以解决此问题。在极少数情况下，可能还有其他原因，我已经提到了一些建议。


现在轮到你了。如果你能够解决此问题，请在评论区告诉我。


*（题图：MJ/b71c9760-4cb1-41de-a336-3e38026bcfeb）*




---


via: <https://itsfoss.com/target-not-found-arch-linux/>


作者：[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

The other day I was trying to install Hyprland on Arch Linux. When I used the [Pacman command to install](https://itsfoss.com/pacman-command/) it, it threw a 'target not found' error.

```
[abhishek@itsfoss ~]$ sudo pacman -S hyprland
[sudo] password for abhishek:
error: target not found: hyprland
[abhishek@itsfoss ~]
```


That was a surprise because I knew that Hyprland was available.

**The fix in my case** was to update the system and in most cases, it fixes this problem.

`sudo pacman -Syu`


Here, the local package database is out of sync. I needed to update the cache. Updating the system is also suggested here.

That's what fixes this error in most cases. However, there could be a few other reasons why you see this error. Let me discuss them in detail here.

## Fix: Update the system

Arch Linux is a [rolling release distribution](https://itsfoss.com/rolling-release/) and it provides updates quite frequently. If you don't update the system every few days, your local package database will be out of sync with the remote mirrors and you'll have trouble installing packages.

The local package database only keeps the metadata of the package like version number, repository URL to get the package from etc.

When you search for a package, pacman provides the search result that says that the package is available. However, the package has an older version number in your local database. When pacman searches for the package in a remote repository (to get the actual packages), it doesn't find the older version URL anymore.

This is what causes the 'target not found' error.

The fix is to update the local database. That could work with `pacman -Sy`

, however, it is recommended to [update the entire Arch Linux system](https://itsfoss.com/update-arch-linux/) to avoid dependency conflicts, among other things.

`sudo pacman -Syu`


In my case, Arch is installed on my secondary system. And since I could not use it for a week or so, the system was outdated. Once I updated it, I could install [Hyprland](https://hyprland.org/).

![Installing Hyperland after updating the database](https://itsfoss.com/content/images/2023/11/installing-hyperland.png)

## Other suggestions to fix 'target not found' error

Here are a few tips on fixing this error if the above method did not fix it for you.

### Double check the package name

It may seem elementary, my dear Watson, but often people just type the package name incorrectly.

Linux is case sensitive and packages are usually named in lowercases. So if you want to use a popular tool named Flameshot, its package name is likely to be flameshot.

Also, some software have different spelling than the common one. For example, it is hyprland and that made me make mistake of typing hyperland (with the usual 'hyper' spelling).

![target not found error in Arch Linux](https://itsfoss.com/content/images/2023/11/pacman-target-not-found-error-arch-linux.png)

In some rare cases, there could be confusion whether it is `l`

or `I`

or `1`

.

Basically, ensure that the name you have entered the package name is correc.

### See if the package is available in the repositories

Arch Linux has a vast number of packages in its repositories. But that does not mean it has every possible Linux packages.

Go to the official Arch Linux package website:

Here, enter the package name and see if the package is available. If yes, which repository it is and on which device it is available.

![Arch Linux package search](https://itsfoss.com/content/images/2023/11/arch-linux-package-search.png)

`x86_64`

is for Intel architecture and any includes ARM architecture is for [Raspberry Pi like devices](https://itsfoss.com/raspberry-pi-alternatives/).

### Ensure that it's not an AUR package

[Arch User Repository (AUR)](https://itsfoss.com/aur-arch-linux/) is the additional community supported platform that provides newer packages.

Now, there are multiple ways to use AUR packages but pacman is not one of them.

Check if the package you are trying to install is an AUR package. Check the official Arch repository first, as explained above. If it's not there, then check the AUR page.

If it's an AUR package, you'll have to [use yay](https://itsfoss.com/install-yay-arch-linux/) or some [other AUR helper](https://itsfoss.com/best-aur-helpers/). You cannot use pacman to install AUR packages.

## Were you able to fix the issue?

Updating the system is what fixes this issue in most cases. In some rare instances, there could be other reasons and I have mentioned some suggestions for them.

Now it's your turn. Let me know in the comment section if you were able to fix this issue or not.