Related articles
- Creating packages
- Downgrading packages
- pacman/Package signing
- pacman/Pacnew and Pacsave
- pacman/Restore local database
- pacman/Rosetta
- pacman/Tips and tricks
- FAQ#Package management
- System maintenance
- Arch Build System
- Official repositories
- Arch User Repository
The pacman package manager is one of the major distinguishing features of Arch Linux. It combines a simple binary package format with an easy-to-use build system. The goal of pacman is to make it possible to easily manage packages, whether they are from the official repositories or the user’s own builds.
Pacman keeps the system up-to-date by synchronizing package lists with the master server. This server/client model also allows the user to download/install packages with a simple command, complete with all required dependencies.
Pacman is written in the C programming language and uses the bsdtar(1) tar format for packaging.
Tip: The pacman package contains tools such as makepkg and vercmp(8). Other useful tools such as pactree and checkupdates are found in pacman-contrib (formerly part of pacman). Run pacman -Ql pacman pacman-contrib | grep -E 'bin/.+'
to see the full list.
Usage
What follows is just a small sample of the operations that pacman can perform. To read more examples, refer to pacman(8).
Tip: For those who have used other Linux distributions before, there is a helpful Pacman Rosetta article.
Installing packages
A package is an archive containing:
- all of the (compiled) files of an application
- metadata about the application, such as application name, version, dependencies, etc.
- installation files and directives for pacman
- (optionally) extra files to make your life easier, such as a start/stop script
Arch’s package manager pacman can install, update, and remove those packages. Using packages instead of compiling and installing programs yourself has various benefits:
- easily updatable: pacman will update existing packages as soon as updates are available
- dependency checks: pacman handles dependencies for you, you only need to specify the program and pacman installs it together with every other program it needs
- clean removal: pacman has a list of every file in a package; this way, no files are unintentionally left behind when you decide to remove a package.
Note:
- Packages often have optional dependencies which are packages that provide additional functionality to the application but not strictly required for running it. When installing a package, pacman will list a package’s optional dependencies, but they will not be found in
pacman.log
. Use the #Querying package databases command to view the optional dependencies of a package. - When installing a package which you require only as a (optional) dependency of some other package (i.e. not required by you explicitly), it is recommended to use the
--asdeps
option. For details, see the #Installation reason section.
Warning: When installing packages in Arch, avoid refreshing the package list without upgrading the system (for example, when a package is no longer found in the official repositories). In practice, do not run pacman -Sy package_name
instead of pacman -Syu package_name
, as this could lead to dependency issues. See System maintenance#Partial upgrades are unsupported and BBS#89328.
Installing specific packages
To install a single package or list of packages, including dependencies, issue the following command:
# pacman -S package_name1 package_name2 ...
To install a list of packages with regex (see this forum thread):
# pacman -S $(pacman -Ssq package_regex)
Sometimes there are multiple versions of a package in different repositories (e.g. extra and testing). To install the version from the extra repository in this example, the repository needs to be defined in front of the package name:
# pacman -S extra/package_name
To install a number of packages sharing similar patterns in their names, one can use curly brace expansion. For example:
# pacman -S plasma-{desktop,mediacenter,nm}
This can be expanded to however many levels needed:
# pacman -S plasma-{workspace{,-wallpapers},pa}
Virtual packages
A virtual package is a special package which does not exist by itself, but is provided by one or more other packages. Virtual packages allow other packages to not name a specific package as a dependency, in case there are several candidates. Virtual packages cannot be installed by their name, instead they become installed in your system when you have installed a package providing the virtual package.
Installing package groups
Some packages belong to a group of packages that can all be installed simultaneously. For example, issuing the command:
# pacman -S gnome
will prompt you to select the packages from the gnome group that you wish to install.
Sometimes a package group will contain a large amount of packages, and there may be only a few that you do or do not want to install. Instead of having to enter all the numbers except the ones you do not want, it is sometimes more convenient to select or exclude packages or ranges of packages with the following syntax:
Enter a selection (default=all): 1-10 15
which will select packages 1 through 10 and 15 for installation, or:
Enter a selection (default=all): ^5-8 ^2
which will select all packages except 5 through 8 and 2 for installation.
To see what packages belong to the gnome group, run:
# pacman -Sg gnome
Also visit https://archlinux.org/groups/ to see what package groups are available.
Note: If a package in the list is already installed on the system, it will be reinstalled even if it is already up-to-date. This behavior can be overridden with the --needed
option.
Removing packages
To remove a single package, leaving all of its dependencies installed:
# pacman -R package_name
To remove a package and its dependencies which are not required by any other installed package:
# pacman -Rs package_name
Warning: When removing a group, such as gnome, this ignores the install reason of the packages in the group, because it acts as though each package in the group is listed separately. Install reason of dependencies is still respected.
The above may sometimes refuse to run when removing a group which contains otherwise needed packages. In this case try:
# pacman -Rsu package_name
To remove a package, its dependencies and all the packages that depend on the target package:
Warning: This operation is recursive, and must be used with care since it can remove many potentially needed packages.
# pacman -Rsc package_name
To remove a package, which is required by another package, without removing the dependent package:
# pacman -Rdd package_name
Pacman saves important configuration files when removing certain applications and names them with the extension: .pacsave. To prevent the creation of these backup files use the -n
option:
# pacman -Rn package_name
Note: Pacman will not remove configurations that the application itself creates (for example «dotfiles» in the home directory).
Upgrading packages
Warning:
- Users are expected to follow the guidance in the System maintenance#Upgrading the system section to upgrade their systems regularly and not blindly run the following command.
- Arch only supports full system upgrades. See System maintenance#Partial upgrades are unsupported and #Installing packages for details.
Pacman can update all packages on the system with just one command. This could take quite a while depending on how up-to-date the system is. The following command synchronizes the repository databases and updates the system’s packages, excluding «local» packages that are not in the configured repositories:
# pacman -Syu
Querying package databases
Pacman queries the local package database with the -Q
flag, the sync database with the -S
flag and the files database with the -F
flag. See pacman -Q --help
, pacman -S --help
and pacman -F --help
for the respective suboptions of each flag.
Pacman can search for packages in the database, searching both in packages’ names and descriptions:
$ pacman -Ss string1 string2 ...
Sometimes, -s
‘s builtin ERE (Extended Regular Expressions) can cause a lot of unwanted results, so it has to be limited to match the package name only; not the description nor any other field:
$ pacman -Ss '^vim-'
To search for already installed packages:
$ pacman -Qs string1 string2 ...
To search for package file names in remote packages:
$ pacman -F string1 string2 ...
To display extensive information about a given package:
$ pacman -Si package_name
For locally installed packages:
$ pacman -Qi package_name
Passing two -i
flags will also display the list of backup files and their modification states:
$ pacman -Qii package_name
To retrieve a list of the files installed by a package:
$ pacman -Ql package_name
To retrieve a list of the files installed by a remote package:
$ pacman -Fl package_name
To verify the presence of the files installed by a package:
$ pacman -Qk package_name
Passing the k
flag twice will perform a more thorough check.
To query the database to know which package a file in the file system belongs to:
$ pacman -Qo /path/to/file_name
To query the database to know which remote package a file belongs to:
$ pacman -F /path/to/file_name
To list all packages no longer required as dependencies (orphans):
$ pacman -Qdt
To list all packages explicitly installed and not required as dependencies:
$ pacman -Qet
See pacman/Tips and tricks for more examples.
Pactree
To view the dependency tree of a package:
$ pactree package_name
To view the dependant tree of a package, pass the reverse flag -r
to pactree, or use whoneeds from pkgtoolsAUR.
Database structure
The pacman databases are normally located at /var/lib/pacman/sync
. For each repository specified in /etc/pacman.conf
, there will be a corresponding database file located there. Database files are gzipped tar archives containing one directory for each package, for example for the which package:
$ tree which-2.21-5
which-2.21-5 |-- desc
The desc
file contains meta data such as the package description, dependencies, file size and MD5 hash.
Cleaning the package cache
Pacman stores its downloaded packages in /var/cache/pacman/pkg/
and does not remove the old or uninstalled versions automatically. This has some advantages:
- It allows to downgrade a package without the need to retrieve the previous version through other means, such as the Arch Linux Archive.
- A package that has been uninstalled can easily be reinstalled directly from the cache directory, not requiring a new download from the repository.
However, it is necessary to deliberately clean up the cache periodically to prevent the directory to grow indefinitely in size.
The paccache(8) script, provided within the pacman-contrib package, deletes all cached versions of installed and uninstalled packages, except for the most recent three, by default:
# paccache -r
Enable and start paccache.timer
to discard unused packages weekly.
You can also define how many recent versions you want to keep. To retain only one past version use:
# paccache -rk1
Add the -u
/--uninstalled
switch to limit the action of paccache to uninstalled packages. For example to remove all cached versions of uninstalled packages, use the following:
# paccache -ruk0
See paccache -h
for more options.
Pacman also has some built-in options to clean the cache and the leftover database files from repositories which are no longer listed in the configuration file /etc/pacman.conf
. However pacman does not offer the possibility to keep a number of past versions and is therefore more aggressive than paccache default options.
To remove all the cached packages that are not currently installed, and the unused sync database, execute:
# pacman -Sc
To remove all files from the cache, use the clean switch twice, this is the most aggressive approach and will leave nothing in the cache directory:
# pacman -Scc
Warning: One should avoid deleting from the cache all past versions of installed packages and all uninstalled packages unless one desperately needs to free some disk space. This will prevent downgrading or reinstalling packages without downloading them again.
pkgcachecleanAUR and pacleanerAUR are two further alternatives to clean the cache.
Additional commands
Download a package without installing it:
# pacman -Sw package_name
Install a ‘local’ package that is not from a remote repository (e.g. the package is from the AUR):
# pacman -U /path/to/package/package_name-version.pkg.tar.zst
To keep a copy of the local package in pacman’s cache, use:
# pacman -U file:///path/to/package/package_name-version.pkg.tar.zst
Install a ‘remote’ package (not from a repository stated in pacman’s configuration files):
# pacman -U http://www.example.com/repo/example.pkg.tar.zst
To inhibit the -S
, -U
and -R
actions, -p
can be used.
Pacman always lists packages to be installed or removed and asks for permission before it takes action.
Installation reason
The pacman database organizes installed packages into two groups, according to installation reason:
- explicitly-installed: packages that were literally passed to a generic pacman
-S
or-U
command; - dependencies: packages that, despite never (in general) having been passed to a pacman installation command, were implicitly installed because they were required by packages explicitly installed.
When installing a package, it is possible to force its installation reason to dependency with:
# pacman -S --asdeps package_name
The command is normally used because explicitly-installed packages may offer optional packages, usually for non-essential features for which the user has discretion.
Tip: Installing optional dependencies with --asdeps
will ensure that, if you remove orphans, pacman will also remove optional packages set this way.
When reinstalling a package, though, the current installation reason is preserved by default.
The list of explicitly-installed packages can be shown with pacman -Qe
, while the complementary list of dependencies can be shown with pacman -Qd
.
To change the installation reason of an already installed package, execute:
# pacman -D --asdeps package_name
Use --asexplicit
to do the opposite operation.
Note: Using --asdeps
and --asexplicit
options when upgrading, such as with pacman -Syu package_name --asdeps
, is discouraged. This would change the installation reason of not only the package being installed, but also the packages being upgraded.
Search for a package that contains a specific file
This article or section is a candidate for merging with pacman/Tips and tricks.
Notes: Looking at #Querying package databases this section duplicates but expands what is already covered there. Either this should be moved inside the previous section or merged as a pacman tip in the dedicated article, which is already linked (Discuss in Talk:Pacman)
Sync the files database:
# pacman -Fy
Search for a package containing a file, e.g.:
$ pacman -F pacman
core/pacman 5.2.1-1 (base base-devel) [installed] usr/bin/pacman usr/share/bash-completion/completions/pacman extra/xscreensaver 5.43-1 usr/lib/xscreensaver/pacman
Tip: You can enable/start pacman-filesdb-refresh.timer
to refresh pacman files database weekly.
For advanced functionality, install pkgfile, which uses a separate database with all files and their associated packages.
What happens during package install/upgrade/removal
When successful, the workflow of a transaction follows five high-level steps plus pre/post transaction hooks:
- Initialize the transaction if there is not a database lock
- Choose which packages will be added or removed in the transaction
- Prepare the transaction, based on flags, by performing sanity checks on the sync databases, packages, and their dependencies
- Commit the transaction:
- When applicable, download packages (
_alpm_sync_load
) - If pre-existing pacman
PreTransaction
hooks apply, they are executed. - Packages are removed that are to-be-replaced, conflicting, or explicitly targeted to be removed
- If there are packages to add, then each package is committed
- If the package has an install script, its
pre_install
function is executed (orpre_upgrade
orpre_remove
in the case of an upgraded or removed package). - Pacman deletes all the files from a pre-existing version of the package (in the case of an upgraded or removed package). However, files that were marked as configuration files in the package are kept (see /Pacnew and Pacsave).
- Pacman untars the package and dumps its files into the file system (in the case of an installed or upgraded package). Files that would overwrite kept, and manually modified, configuration files (see previous step), are stored with a new name (.pacnew).
- If the package has an install script, its
post_install
function is executed (orpost_upgrade
orpost_remove
in the case of an upgraded or removed package).
- If the package has an install script, its
- If pacman
PostTransaction
hooks that exist at the end of the transaction apply, they are executed.
- When applicable, download packages (
- Release the transaction and transaction resource (i.e. database lock)
Configuration
Pacman’s settings are located in /etc/pacman.conf
: this is the place where the user configures the program to work in the desired manner. In-depth information about the configuration file can be found in pacman.conf(5).
General options
General options are in the [options]
section. Read pacman.conf(5) or look in the default pacman.conf
for information on what can be done here.
Comparing versions before updating
To see old and new versions of available packages, uncomment the «VerbosePkgLists» line in /etc/pacman.conf
. The output of pacman -Syu
will be like this:
Package (6) Old Version New Version Net Change Download Size extra/libmariadbclient 10.1.9-4 10.1.10-1 0.03 MiB 4.35 MiB extra/libpng 1.6.19-1 1.6.20-1 0.00 MiB 0.23 MiB extra/mariadb 10.1.9-4 10.1.10-1 0.26 MiB 13.80 MiB
Enabling parallel downloads
Pacman 6.0 introduced the option to download packages in parallel. ParallelDownloads
under [options]
needs to be set to a positive integer in /etc/pacman.conf
to use this feature (e.g., 5
). Packages will otherwise be downloaded sequentially if this option is unset.
Skip package from being upgraded
Warning: Be careful in skipping packages, since partial upgrades are unsupported.
To have a specific package skipped when upgrading the system, add this line in the [options]
section:
IgnorePkg=linux
For multiple packages use a space-separated list, or use additional IgnorePkg
lines. Also, glob patterns can be used. If you want to skip packages just once, you can also use the --ignore
option on the command-line — this time with a comma-separated list.
It will still be possible to upgrade the ignored packages using pacman -S
: in this case pacman will remind you that the packages have been included in an IgnorePkg
statement.
Skip package group from being upgraded
Warning: Be careful in skipping package groups, since partial upgrades are unsupported.
As with packages, skipping a whole package group is also possible:
IgnoreGroup=gnome
Skip file from being upgraded
All files listed with a NoUpgrade
directive will never be touched during a package install/upgrade, and the new files will be installed with a .pacnew extension.
NoUpgrade=path/to/file
Multiple files can be specified like this:
NoUpgrade=path/to/file1 path/to/file2
Note: The path refers to files in the package archive. Therefore, do not include the leading slash.
Skip files from being installed to system
To always skip installation of specific directories list them under NoExtract
. For example, to avoid installation of systemd units use this:
NoExtract=usr/lib/systemd/system/*
Later rules override previous ones, and you can negate a rule by prepending !
.
Tip: Pacman issues warning messages about missing locales when updating a package for which locales have been cleared by localepurge or bleachbit. Commenting the CheckSpace
option in pacman.conf
suppresses such warnings, but consider that the space-checking functionality will be disabled for all packages.
Maintain several configuration files
If you have several configuration files (e.g. main configuration and configuration with testing repository enabled) and would have to share options between configurations you may use Include
option declared in the configuration files, e.g.:
Include = /path/to/common/settings
where /path/to/common/settings
file contains the same options for both configurations.
Hooks
Pacman can run pre- and post-transaction hooks from the /usr/share/libalpm/hooks/
directory; more directories can be specified with the HookDir
option in pacman.conf
, which defaults to /etc/pacman.d/hooks
. Hook file names must be suffixed with .hook. Pacman hooks are not interactive.
Pacman hooks are used, for example, in combination with systemd-sysusers
and systemd-tmpfiles
to automatically create system users and files during the installation of packages. For example, tomcat8 specifies that it wants a system user called tomcat8
and certain directories owned by this user. The pacman hooks systemd-sysusers.hook
and systemd-tmpfiles.hook
invoke systemd-sysusers
and systemd-tmpfiles
when pacman determines that tomcat8 contains files specifying users and tmp files.
For more information on alpm hooks, see alpm-hooks(5).
Repositories and mirrors
Besides the special [options] section, each other [section]
in pacman.conf
defines a package repository to be used. A repository is a logical collection of packages, which are physically stored on one or more servers: for this reason each server is called a mirror for the repository.
Repositories are distinguished between official and unofficial. The order of repositories in the configuration file matters; repositories listed first will take precedence over those listed later in the file when packages in two repositories have identical names, regardless of version number. In order to use a repository after adding it, you will need to upgrade the whole system first.
Each repository section allows defining the list of its mirrors directly or in a dedicated external file through the Include
directive; for example, the mirrors for the official repositories are included from /etc/pacman.d/mirrorlist
. See the Mirrors article for mirror configuration.
Package cache directory
Pacman stores downloaded package files in cache, in a directory denoted by CacheDir
in [options] section of pacman.conf
(defaults to /var/cache/pacman/pkg/
if not set).
Cache directory may grow over time, even if keeping just the freshest versions of installed packages.
If you want to move that directory to some more convenient place, do one of the following:
- Set the
CacheDir
option inpacman.conf
to new directory. Remember to retain the trailing slash. This is the recommended solution. - Mount a dedicated partition or e.g. Btrfs subvolume in
/var/cache/pacman/pkg/
. - Bind-mount selected directory in
/var/cache/pacman/pkg/
.
Warning: Do not symlink the /var/cache/pacman/pkg/
directory to some other location. It will cause pacman to misbehave, especially when pacman attempts to update itself.
Package security
Pacman supports package signatures, which add an extra layer of security to the packages. The default configuration, SigLevel = Required DatabaseOptional
, enables signature verification for all the packages on a global level. This can be overridden by per-repository SigLevel
lines. For more details on package signing and signature verification, take a look at pacman-key.
Troubleshooting
«Failed to commit transaction (conflicting files)» error
If you see the following error: [1]
error: could not prepare transaction error: failed to commit transaction (conflicting files) package: /path/to/file exists in filesystem Errors occurred, no packages were upgraded.
This is happening because pacman has detected a file conflict, and by design, will not overwrite files for you. This is by design, not a flaw.
If you know that you have not used another package manager like pip to install these files, the problem is usually trivial to solve (although to be sure, you should try to find out how these files got there in the first place). A safe way is to first check if another package owns the file (pacman -Qo /path/to/file
). If the file is owned by another package, file a bug report. If the file is not owned by another package, you rename the file which ‘exists in filesystem’ and re-issue the update command. If all goes well, the file may then be removed. Importantly, do not do this if another package manager like pip believes it owns this file, because while this pacman transaction may now succeed, the other package manager will become deeply unhappy!
If you have, however, installed a program manually without using pacman, for example through make install
, pip, or similar, you have to remove/uninstall this program with all of its files. See also Pacman tips#Identify files not owned by any package.
Every installed package provides a /var/lib/pacman/local/package-version/files
file that contains metadata about this package. If this file gets corrupted, is empty or goes missing, it results in file exists in filesystem
errors when trying to update the package. Such an error usually concerns only one package. Instead of manually renaming and later removing all the files that belong to the package in question, you may explicitly run pacman -S --overwrite glob package
to force pacman to overwrite files that match glob
.
«Failed to commit transaction (invalid or corrupted package)» error
Look for .part files (partially downloaded packages) in /var/cache/pacman/pkg/
and remove them (often caused by usage of a custom XferCommand
in pacman.conf
).
# find /var/cache/pacman/pkg/ -iname "*.part" -delete
That same error may also appear if archlinux-keyring is out-of-date, preventing pacman from verifying signatures. See Pacman/Package signing#Upgrade system regularly for the fix and how to avoid it in the future.
«Failed to init transaction (unable to lock database)» error
When pacman is about to alter the package database, for example installing a package, it creates a lock file at /var/lib/pacman/db.lck
. This prevents another instance of pacman from trying to alter the package database at the same time.
If pacman is interrupted while changing the database, this stale lock file can remain. If you are certain that no instances of pacman are running then delete the lock file:
# rm /var/lib/pacman/db.lck
Tip: You can run fuser /var/lib/pacman/db.lck
as root to verify if there is any process still using it.
Packages cannot be retrieved on installation
This error manifests as Not found in sync db
, Target not found
or Failed retrieving file
.
Firstly, ensure the package actually exists. If certain the package exists, your package list may be out-of-date. Try running pacman -Syu
to force a refresh of all package lists and upgrade. Also make sure the selected mirrors are up-to-date and repositories are correctly configured.
It could also be that the repository containing the package is not enabled on your system, e.g. the package could be in the multilib repository, but multilib is not enabled in your pacman.conf
.
See also FAQ#Why is there only a single version of each shared library in the official repositories?.
Pacman crashes during an upgrade
In the case that pacman crashes with a «database write» error while removing packages, and reinstalling or upgrading packages fails thereafter, do the following:
- Boot using the Arch installation media. Preferably use a recent media so that the pacman version matches/is newer than the system.
- Mount the system’s root filesystem, e.g.,
mount /dev/sdaX /mnt
as root, and check the mount has sufficient space withdf -h
- Mount the proc, sys and dev filesystems as well:
mount -t proc proc /mnt/proc; mount --rbind /sys /mnt/sys; mount --rbind /dev /mnt/dev
- If the system uses default database and directory locations, you can now update the system’s pacman database and upgrade it via
pacman --sysroot /mnt -Syu
as root.- Alternatively, if you cannot update/upgrade, refer to Pacman/Tips and tricks#Reinstalling all packages.
- After the upgrade, one way to double-check for not upgraded but still broken packages:
find /mnt/usr/lib -size 0
- Followed by a re-install of any still broken package via
pacman --sysroot /mnt -S package
.
pacman: command not found
If /var/cache/pacman/pkg
is a symlink, pacman will try to make a directory instead and thus remove this symlink during self-upgrade. This will cause the update to fail. As a result, /usr/bin/pacman
and other contents of the pacman package will be missing.
Never symlink /var/cache/pacman/pkg
because it is controlled by pacman. Use the CacheDir
option or a bind mount instead; see #Package cache directory.
If you have already encountered this problem and broke your system, you can manually extract /usr
contents from the package to restore pacman and then reinstall it properly; see FS#73306 and related forum thread for details.
Manually reinstalling pacman
Using pacman-static
pacman-staticAUR is a statically compiled version of pacman, so it will be able to run even when the libraries on the system are not working. This can also come in handy when a partial upgrade was performed and pacman can not run anymore.
The pinned comment and the PKGBUILD provides a way to directly download the binary, which can be used to reinstall pacman or to upgrade the entire system in case of partial upgrades.
Using an external pacman
If even pacman-static
does not work, it is possible to recover using an external pacman. One of the easiest methods to do so is by using the archiso and simply using --sysroot
or --root
to specify the mount point. See Chroot#Using chroot on how to mount the necessary filesystems required by --sysroot
.
Warning: It is extremely easy to break your system even worse using this approach. Use this only as a last resort if the method from #Pacman crashes during an upgrade is not an option.
Even if pacman is terribly broken, you can fix it manually by downloading the latest packages and extracting them to the correct locations. The rough steps to perform are:
- Determine the pacman dependencies to install
- Download each package from a mirror of your choice
- Extract each package to root
- Reinstall these packages with
pacman -S --overwrite
to update the package database accordingly - Do a full system upgrade
If you have a healthy Arch system on hand, you can see the full list of dependencies with:
$ pacman -Q $(pactree -u pacman)
But you may only need to update a few of them depending on your issue. An example of extracting a package is
# tar -xvpwf package.tar.zst -C / --exclude .PKGINFO --exclude .INSTALL --exclude .MTREE --exclude .BUILDINFO
Note the use of the w
flag for interactive mode. Running non-interactively is very risky since you might end up overwriting an important file. Also take care to extract packages in the correct order (i.e. dependencies first). This forum post contains an example of this process where only a couple pacman dependencies are broken.
«Unable to find root device» error after rebooting
Most likely the initramfs became corrupted during a kernel update (improper use of pacman’s --overwrite
option can be a cause). There are two options; first, try the Fallback entry.
Tip: In case you removed the Fallback entry, you can always press the Tab
key when the boot loader menu shows up (for Syslinux) or e
(for GRUB or systemd-boot), rename it initramfs-linux-fallback.img
and press Enter
or b
(depending on your boot loader) to boot with the new parameters.
Once the system starts, run this command (for the stock linux kernel) either from the console or from a terminal to rebuild the initramfs image:
# mkinitcpio -p linux
If that does not work, from a current Arch release (CD/DVD or USB stick), mount your root and boot partitions to /mnt
and /mnt/boot
, respectively. Then chroot using arch-chroot:
# arch-chroot /mnt # pacman -Syu mkinitcpio systemd linux
Note:
- If you do not have a current release or if you only have some other «live» Linux distribution laying around, you can chroot using the old fashioned way. Obviously, there will be more typing than simply running the
arch-chroot
script. - If pacman fails with
Could not resolve host
, please check your internet connection. - If you cannot enter the arch-chroot or chroot environment but need to re-install packages, you can use the command
pacman --sysroot /mnt -Syu foo bar
to use pacman on your root partition.
Reinstalling the kernel (the linux package) will automatically re-generate the initramfs image with mkinitcpio -p linux
. There is no need to do this separately.
Afterwards, it is recommended that you run exit
, umount /mnt/{boot,}
and reboot
.
«Warning: current locale is invalid; using default «C» locale» error
As the error message says, your locale is not correctly configured. See Locale.
Pacman does not honor proxy settings
Make sure that the relevant environment variables ($http_proxy
, $ftp_proxy
etc.) are set up. If you use pacman with sudo, you need to configure sudo to pass these environment variables to pacman. Also, ensure the configuration of dirmngr has honor-http-proxy
in /etc/pacman.d/gnupg/dirmngr.conf
to honor the proxy when refreshing the keys.
How do I reinstall all packages, retaining information on whether something was explicitly installed or as a dependency?
To reinstall all the native packages: pacman -Qnq | pacman -S -
or pacman -S $(pacman -Qnq)
(the -S
option preserves the installation reason by default).
You will then need to reinstall all the foreign packages, which can be listed with pacman -Qmq
.
«Cannot open shared object file» error
It looks like previous pacman transaction removed or corrupted shared libraries needed for pacman itself.
To recover from this situation, you need to unpack required libraries to your filesystem manually. First find what package contains the missed library and then locate it in the pacman cache (/var/cache/pacman/pkg/
). Unpack required shared library to the filesystem. This will allow to run pacman.
Now you need to reinstall the broken package. Note that you need to use --overwrite
flag as you just unpacked system files and pacman does not know about it. Pacman will correctly replace our shared library file with one from package.
That’s it. Update the rest of the system.
Freeze of package downloads
Some issues have been reported regarding network problems that prevent pacman from updating/synchronizing repositories. [2] [3] When installing Arch Linux natively, these issues have been resolved by replacing the default pacman file downloader with an alternative (see Improve pacman performance for more details). When installing Arch Linux as a guest OS in VirtualBox, this issue has also been addressed by using Host interface instead of NAT in the machine properties.
Failed retrieving file ‘core.db’ from mirror
If you receive this error message with correct mirrors, try setting a different name server.
error: ‘local-package.pkg.tar’: permission denied
If you want to install a package on an sshfs mount using pacman -U
and receive this error, move the package to a local directory and try to install again.
error: could not determine cachedir mount point /var/cache/pacman/pkg
Upon executing, e.g., pacman -Syu
inside a chroot environment an error is encountered:
error: could not determine cachedir mount point /var/cache/pacman/pkg error: failed to commit transaction (not enough free disk space)
This is frequently caused by the chroot directory not being a mountpoint when the chroot is entered. See the note at Install Arch Linux from existing Linux#Downloading basic tools for a solution, and arch-chroot(8) for an explanation and an example of using bind mounting to make the chroot directory a mountpoint.
error: GPGME error: No data
If you are unable to update packages and receive this error, try rm -r /var/lib/pacman/sync/
before attempting to update.
See also
- Pacman Home Page
- libalpm(3)
- pacman(8)
- pacman.conf(5)
- repo-add(8)
I ran sudo pacman -Syu
and I got some interesting errors reading:
error: failed to commit transaction (conflicting files)
and a long list of files followed by exists in filesystem
. Full output is here: http://ix.io/lLw
It appears that many of these files are not associated with a package when I checked them with pacman -Qo <path-to-file>
, but I did not check them all. I had a weak connection when I ran pacman -Syu
, but I get the same errors when I updated later: http://ix.io/lLx
What should I do? Should I check all files and delete the ones that do not have an associated package? Should I force update (with sudo pacman -S --force <package-name>
?)
Update
I tried running sudo pacman -S --force <package-name>
and got this:
[my-pc]/home/average-joe$ pacman -Qo /usr/lib/python3.5/site-packages/PyYAML-3.11-py3.5.egg-info
error: No package owns /usr/lib/python3.5/site-packages/PyYAML-3.11-py3.5.egg-info
It looks like pacman -S --force <package
does not overwrite directories that contain files. From the man:
Using —force will not allow overwriting a directory with a file or installing packages with conflicting files and directories.
Should I just delete the conflicting directories? (they do not have associated packages)
asked Nov 2, 2015 at 11:31
5
After pacman finally deprecated the --force
option and made the surrogate --overwrite
option work as expected, the following usage pattern should be noted.
A command to reproduce the --force
option that blindly overwrites anything that conflicts is this:
sudo pacman -S --overwrite * <package_name>
Or
sudo pacman -S --overwrite "*" <package_name>
The tricky part is escaping the wildcard to stop the shell from expanding it first.
answered Oct 30, 2019 at 5:51
nixnix
9666 silver badges4 bronze badges
3
Ok, it looks like running sudo pacman -S --force <package-name>
works, but it doesn’t resolve conflicting directories. In such cases, running sudo rm -rf
on the conflicting directories, followed by sudo pacman -S --force <package-name>
works.
Now my pacman -Syu
resolves well.
answered Nov 2, 2015 at 11:43
modulitosmodulitos
2,9778 gold badges29 silver badges43 bronze badges
9
tl;dr: Uninstall the conflicting application before running pacman
.
pacman
(and other package managers) keep an index of packages and files that they manage (pacman --query --list
). Some files, such as configuration, will be marked as modifiable and will not be overwritten during upgrade (except in special circumstances, where the package manager will typically move away the old file before creating the new one). Other files will be marked as unmodifiable. If another application changes those files in any way without updating the index accordingly there’s no way for the package manager to know what to do with those files during an upgrade.
Many applications installed using the standard ./configure && make && sudo make install
pattern can be uninstalled using sudo make uninstall
. If you have installed the application in some other way you might have to something else to uninstall it. In general it can be a good idea to keep a copy of installation files somewhere (for example ~/install
) to be able to reliably uninstall them in such cases. Just removing the conflicting files will probably leave other files lying around, which could conceivably cause other problems.
When installing software with other package managers there are ways to isolate those from the system files. This is an established best practice for example during software development, where you really want to keep versions consistent and avoid conflicts with other software. Examples include:
- Python Virtualenv (example; in use)
- Ruby Version Manager
answered Nov 2, 2015 at 12:57
l0b0l0b0
48.9k41 gold badges188 silver badges343 bronze badges
1
The correct way to upgrade and overwrite conflicting packages is:
sudo pacman --overwrite "*" -Syu
answered Nov 18, 2020 at 20:29
hLkhLk
2302 silver badges5 bronze badges
TLDR;
- Get a list of the offending files (copy and paste pacman’s output into a file).
- Use awk to strip out everything but the file paths into a new list.
- Use while to move the offending files out of the way, based on the list.
- Run
sudo pacman -Syu
again.edited to add TLDR and fix typos
Although I’m pretty sure I haven’t been doing anything stupid, I’ve had this problem maybe every other time I’ve tried to update since I’ve been using Manjaro; three or four times within two months. Point being, this fixes it.
Get a list of your files.
When the update fails in your terminal window, you get this:
error: failed to commit transaction (conflicting files)
evilfile: /usr/bin/evilfile exists in filesystem
libx000: /usr/lib/libx000.so.f.u.loser exists in filesystem
accountsservice: /usr/share/locale/ru/LC_MESSAGES/accounts-service.mo.yu.dnt.evn.spk.russian exists in filesystem
… and a lot more.
-
Copy the output from the terminal, and put it in a file. I used nano, and named mine «files,» as in ~/work/files.
-
Strip extraneous info:
cat files | awk '{print $2}' >> ~/work/files2
This takes the second «word» from each line and prints it to files2.
Deal with the files
-
You could delete them, move them, or rename them.
-
If something breaks, it’s easiest to fix if we break it by moving it instead of deleting or renaming it:
mkdir ~/work/oldfiles
while read -r file; do sudo mv -- "$file" ~/work/oldfiles/$file; done < files2 -
If you really want to delete them, which there is no reason to do (DANGER DANGER): while read -r file; do sudo rm — «$file»; done < files2
Updating
-
To get —overwrite to work, which we need to do to get pacman to realize the package isn’t broken, you need the following syntax:
sudo pacman -S package_name --overwrite /location/of/thing
- In my case:
sudo pacman -S libidn2 --overwrite /usr/lib/libidn2.so.0
- Following the example:
sudo pacman -S libx000 --overwrite /usr/lib/libx000.so.f.u.loser
- In my case:
-
I had a cute problem where if I deleted the libidn2.so.0 symlink, nothing worked, and when I put it back, I got the «exists on filesystem» error. The above, with —overwrite, is all that worked for me.
-
Finally:
sudo pacman -Syu
answered Mar 8, 2019 at 2:18
1
I was installing packages that I usually install with pip via pacman because of this. But some packages arent found in pacman repos. I think we should avoid installing pip with sudo privilegies and istead:
pip install pillow --user
—user flag makes pip install packages in your home directory instead, which doesn’t require any special privileges.https://stackoverflow.com/questions/42988977/what-is-the-purpose-pip-install-user
answered Jul 25, 2018 at 16:48
If you have many files as me,
sudo pacman --force -Syyu
resolves all issues.
Jeff Schaller♦
65.2k34 gold badges106 silver badges240 bronze badges
answered May 21, 2019 at 11:08
2
when you conflicting files/ file already exists. do the following.
pacman -Qo "path_to_file"
if the out is «No package owns this file» then you can delete the file without any worry.
for me usually i get file already exists error on /usr/lib/python3.8/»folder_X»/….
so i run pacman -Qo /usr/lib/python3.8/folder_X
which usually return «No Package owns this file» and i just remove it.
sudo rm -rf /usr/lib/python3.8/folder_X
till date i have not had a situation where a file or folder was actually owned by a package. so i can’t really advice on what to do in that situation.
Hope this Helps
answered Apr 16, 2020 at 7:54
Содержание
- error: failed to commit transaction (conflicting files)
- Arch Linux
- #1 2008-02-23 01:18:28
- Pacman «error: failed to commit transaction (conflicting files)»
- #2 2008-02-23 02:06:46
- Re: Pacman «error: failed to commit transaction (conflicting files)»
- #3 2008-02-23 18:30:57
- Re: Pacman «error: failed to commit transaction (conflicting files)»
- #4 2008-02-23 19:16:45
- Re: Pacman «error: failed to commit transaction (conflicting files)»
- #5 2009-05-21 22:13:42
- Re: Pacman «error: failed to commit transaction (conflicting files)»
- pacman
- Usage
- Installing packages
- Installing specific packages
- Installing package groups
- Removing packages
- Upgrading packages
- Querying package databases
- Pactree
- Database structure
- Cleaning the package cache
- Additional commands
- Installation reason
- Search for a package that contains a specific file
- What happens during package install/upgrade/removal
- Configuration
- General options
- Comparing versions before updating
- Enabling parallel downloads
- Skip package from being upgraded
- Skip package group from being upgraded
- Skip file from being upgraded
- Skip files from being installed to system
- Maintain several configuration files
- Hooks
- Repositories and mirrors
- Package cache directory
- Package security
- Troubleshooting
- «Failed to commit transaction (conflicting files)» error
- «Failed to commit transaction (invalid or corrupted package)» error
- «Failed to init transaction (unable to lock database)» error
- Packages cannot be retrieved on installation
- Pacman crashes during an upgrade
- pacman: command not found
- Manually reinstalling pacman
- Using pacman-static
- Using an external pacman
- By manually extracting
- «Unable to find root device» error after rebooting
- «Warning: current locale is invalid; using default «C» locale» error
- Pacman does not honor proxy settings
- How do I reinstall all packages, retaining information on whether something was explicitly installed or as a dependency?
- «Cannot open shared object file» error
- Freeze of package downloads
- Failed retrieving file ‘core.db’ from mirror
- error: ‘local-package.pkg.tar’: permission denied
- error: could not determine cachedir mount point /var/cache/pacman/pkg
- error: GPGME error: No data
error: failed to commit transaction (conflicting files)
…
(система свежая, только установленная.)
error: could not prepare transaction
error: failed to commit transaction (conflicting files)
package: /path/to/file exists in filesystem
Errors occurred, no packages were upgraded.
Почему это происходит: pacman при обнаружении конфликтующих файлов, по умолчанию, не будет их перезаписывать автоматически. Это не ошибка, так сделано специально.
Вопрос решается тривиально. Сначала проверьте не принадлежит ли файл другому пакету: (pacman -Qo /path/to/file). Если принадлежит — создайте отчет об ошибке. Если проблемный файл не нужен другим пакетам — переименуйте его и перезапустите команду обновления. Если в дальнейшем проблем не возникнет, то старый файл можно удалить.
Если программа была установлена вручную, без использования pacman или его оболочек, вам нужно будет удалить программу и все ее файлы, а затем выполнить установку при помощи pacman.
Информация, о каждом установленном файле, храниться в файле с метаданными пакета /var/lib/pacman/local/$package-$version/files. При повреждении этого файла (может быть пустым или отсутствовать), во время обновления пакета, и будет получена ошибка — “file exists in filesystem” (“файл существует в файловой системе”).
Обычно такие ошибки возникают во время установки или обновления всего лишь одного пакета, поэтому вместо ручного переименования или удаления конфликтующих файлов, принадлежащих данному пакету, выполните pacman -S –force $package, после этой команды pacman принудительно перезапишет эти файлы.
Никогда не запускайте pacman -Syu –force.
В моем случае нужно pacman -Syu –force. но этого не советуют… что делать?(
Источник
Arch Linux
You are not logged in.
#1 2008-02-23 01:18:28
Pacman «error: failed to commit transaction (conflicting files)»
When I try to install some packages or do -Syu , I get this error:
cleaning up. done.
(7/7) checking for file conflicts [#####################] 100%
error: could not prepare transaction
error: failed to commit transaction (conflicting files)
gcc-libs: /usr/lib/libgcc_s.so exists in filesystem
gcc-libs: /usr/lib/libgcc_s.so.1 exists in filesystem
gcc-libs: /usr/lib/libgomp.a exists in filesystem
gcc-libs: /usr/lib/libgomp.so exists in filesystem
gcc-libs: /usr/lib/libgomp.so.1 exists in filesystem
gcc-libs: /usr/lib/libgomp.so.1.0.0 exists in filesystem
gcc-libs: /usr/lib/libgomp.spec exists in filesystem
gcc-libs: /usr/lib/libmudflap.a exists in filesystem
gcc-libs: /usr/lib/libmudflap.so exists in filesystem
gcc-libs: /usr/lib/libmudflap.so.0 exists in filesystem
gcc-libs: /usr/lib/libmudflap.so.0.0.0 exists in filesystem
gcc-libs: /usr/lib/libmudflapth.a exists in filesystem
gcc-libs: /usr/lib/libmudflapth.so exists in filesystem
gcc-libs: /usr/lib/libmudflapth.so.0 exists in filesystem
gcc-libs: /usr/lib/libmudflapth.so.0.0.0 exists in filesystem
gcc-libs: /usr/lib/libobjc.a exists in filesystem
gcc-libs: /usr/lib/libobjc.so exists in filesystem
gcc-libs: /usr/lib/libobjc.so.2 exists in filesystem
gcc-libs: /usr/lib/libobjc.so.2.0.0 exists in filesystem
gcc-libs: /usr/lib/libssp.a exists in filesystem
gcc-libs: /usr/lib/libssp.so exists in filesystem
gcc-libs: /usr/lib/libssp.so.0 exists in filesystem
gcc-libs: /usr/lib/libssp.so.0.0.0 exists in filesystem
gcc-libs: /usr/lib/libssp_nonshared.a exists in filesystem
gcc-libs: /usr/lib/libstdc++.a exists in filesystem
gcc-libs: /usr/lib/libstdc++.so exists in filesystem
gcc-libs: /usr/lib/libstdc++.so.6 exists in filesystem
gcc-libs: /usr/lib/libstdc++.so.6.0.9 exists in filesystem
gcc-libs: /usr/lib/libsupc++.a exists in filesystem
gcc-libs: /usr/share/locale/de/LC_MESSAGES/libstdc++.mo exists in filesystem
gcc-libs: /usr/share/locale/fr/LC_MESSAGES/libstdc++.mo exists in filesystem
errors occurred, no packages were upgraded.
Not sure what to do! Thanks in advance for any help.
#2 2008-02-23 02:06:46
Re: Pacman «error: failed to commit transaction (conflicting files)»
Try pacman -Syuf.
Or, pacman -Sc
Then:
Pacman -Syu
Prediction. This year will be a very odd year!
Hard work does not kill people but why risk it: Charlie Mccarthy
A man is not complete until he is married..then..he is finished.
When ALL is lost, what can be found? Even bytes get lonely for a little bit! X-ray confirms Iam spineless!
#3 2008-02-23 18:30:57
Re: Pacman «error: failed to commit transaction (conflicting files)»
Since all of those seem to belong to the same package (gcc-libs), I’d think it would be a bit safer to do pacman -Sf gcc-libs rather than -Syuf. That way if something goes wrong with another package you’d at least know about it.
#4 2008-02-23 19:16:45
Re: Pacman «error: failed to commit transaction (conflicting files)»
Since all of those seem to belong to the same package (gcc-libs), I’d think it would be a bit safer to do pacman -Sf gcc-libs rather than -Syuf. That way if something goes wrong with another package you’d at least know about it.
That’s right. I think -Suf shouldn’t even be allowed. But arch is about letting the power to the user, right?
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
#5 2009-05-21 22:13:42
Re: Pacman «error: failed to commit transaction (conflicting files)»
I got a similar error trying to upgrade libdvdread:
Источник
pacman
The pacman package manager is one of the major distinguishing features of Arch Linux. It combines a simple binary package format with an easy-to-use build system. The goal of pacman is to make it possible to easily manage packages, whether they are from the official repositories or the user’s own builds.
Pacman keeps the system up-to-date by synchronizing package lists with the master server. This server/client model also allows the user to download/install packages with a simple command, complete with all required dependencies.
Pacman is written in the C programming language and uses the bsdtar(1) tar format for packaging.
Usage
What follows is just a small sample of the operations that pacman can perform. To read more examples, refer to pacman(8) .
Installing packages
A package is an archive containing:
- all of the (compiled) files of an application
- metadata about the application, such as application name, version, dependencies, etc.
- installation files and directives for pacman
- (optionally) extra files to make your life easier, such as a start/stop script
Arch’s package manager pacman can install, update, and remove those packages. Using packages instead of compiling and installing programs yourself has various benefits:
- easily updatable: pacman will update existing packages as soon as updates are available
- dependency checks: pacman handles dependencies for you, you only need to specify the program and pacman installs it together with every other program it needs
- clean removal: pacman has a list of every file in a package; this way, no files are unintentionally left behind when you decide to remove a package.
Installing specific packages
To install a single package or list of packages, including dependencies, issue the following command:
To install a list of packages with regex (see this forum thread):
Sometimes there are multiple versions of a package in different repositories (e.g. extra and testing). To install the version from the extra repository in this example, the repository needs to be defined in front of the package name:
To install a number of packages sharing similar patterns in their names, one can use curly brace expansion. For example:
This can be expanded to however many levels needed:
Virtual packages
A virtual package is a special package which does not exist by itself, but is provided by one or more other packages. Virtual packages allow other packages to not name a specific package as a dependency, in case there are several candidates. Virtual packages cannot be installed by their name, instead they become installed in your system when you have installed a package providing the virtual package.
Installing package groups
Some packages belong to a group of packages that can all be installed simultaneously. For example, issuing the command:
will prompt you to select the packages from the gnome group that you wish to install.
Sometimes a package group will contain a large amount of packages, and there may be only a few that you do or do not want to install. Instead of having to enter all the numbers except the ones you do not want, it is sometimes more convenient to select or exclude packages or ranges of packages with the following syntax:
which will select packages 1 through 10 and 15 for installation, or:
which will select all packages except 5 through 8 and 2 for installation.
To see what packages belong to the gnome group, run:
Also visit https://archlinux.org/groups/ to see what package groups are available.
Removing packages
To remove a single package, leaving all of its dependencies installed:
To remove a package and its dependencies which are not required by any other installed package:
The above may sometimes refuse to run when removing a group which contains otherwise needed packages. In this case try:
To remove a package, its dependencies and all the packages that depend on the target package:
To remove a package, which is required by another package, without removing the dependent package:
Pacman saves important configuration files when removing certain applications and names them with the extension: .pacsave. To prevent the creation of these backup files use the -n option:
Upgrading packages
Pacman can update all packages on the system with just one command. This could take quite a while depending on how up-to-date the system is. The following command synchronizes the repository databases and updates the system’s packages, excluding «local» packages that are not in the configured repositories:
Querying package databases
Pacman queries the local package database with the -Q flag, the sync database with the -S flag and the files database with the -F flag. See pacman -Q —help , pacman -S —help and pacman -F —help for the respective suboptions of each flag.
Pacman can search for packages in the database, searching both in packages’ names and descriptions:
Sometimes, -s ‘s builtin ERE (Extended Regular Expressions) can cause a lot of unwanted results, so it has to be limited to match the package name only; not the description nor any other field:
To search for already installed packages:
To search for package file names in remote packages:
To display extensive information about a given package:
For locally installed packages:
Passing two -i flags will also display the list of backup files and their modification states:
To retrieve a list of the files installed by a package:
To retrieve a list of the files installed by a remote package:
To verify the presence of the files installed by a package:
Passing the k flag twice will perform a more thorough check.
To query the database to know which package a file in the file system belongs to:
To query the database to know which remote package a file belongs to:
To list all packages no longer required as dependencies (orphans):
To list all packages explicitly installed and not required as dependencies:
Pactree
To view the dependency tree of a package:
To view the dependant tree of a package, pass the reverse flag -r to pactree, or use whoneeds from pkgtools AUR .
Database structure
The pacman databases are normally located at /var/lib/pacman/sync . For each repository specified in /etc/pacman.conf , there will be a corresponding database file located there. Database files are gzipped tar archives containing one directory for each package, for example for the which package:
The desc file contains meta data such as the package description, dependencies, file size and MD5 hash.
Cleaning the package cache
Pacman stores its downloaded packages in /var/cache/pacman/pkg/ and does not remove the old or uninstalled versions automatically. This has some advantages:
- It allows to downgrade a package without the need to retrieve the previous version through other means, such as the Arch Linux Archive.
- A package that has been uninstalled can easily be reinstalled directly from the cache directory, not requiring a new download from the repository.
However, it is necessary to deliberately clean up the cache periodically to prevent the directory to grow indefinitely in size.
The paccache(8) script, provided within the pacman-contrib package, deletes all cached versions of installed and uninstalled packages, except for the most recent three, by default:
Enable and start paccache.timer to discard unused packages weekly.
You can also define how many recent versions you want to keep. To retain only one past version use:
Add the -u / —uninstalled switch to limit the action of paccache to uninstalled packages. For example to remove all cached versions of uninstalled packages, use the following:
See paccache -h for more options.
Pacman also has some built-in options to clean the cache and the leftover database files from repositories which are no longer listed in the configuration file /etc/pacman.conf . However pacman does not offer the possibility to keep a number of past versions and is therefore more aggressive than paccache default options.
To remove all the cached packages that are not currently installed, and the unused sync database, execute:
To remove all files from the cache, use the clean switch twice, this is the most aggressive approach and will leave nothing in the cache directory:
pkgcacheclean AUR and pacleaner AUR are two further alternatives to clean the cache.
Additional commands
Download a package without installing it:
Install a ‘local’ package that is not from a remote repository (e.g. the package is from the AUR):
To keep a copy of the local package in pacman’s cache, use:
Install a ‘remote’ package (not from a repository stated in pacman’s configuration files):
To inhibit the -S , -U and -R actions, -p can be used.
Pacman always lists packages to be installed or removed and asks for permission before it takes action.
Installation reason
The pacman database organizes installed packages into two groups, according to installation reason:
- explicitly-installed: packages that were literally passed to a generic pacman -S or -U command;
- dependencies: packages that, despite never (in general) having been passed to a pacman installation command, were implicitly installed because they were required by packages explicitly installed.
When installing a package, it is possible to force its installation reason to dependency with:
The command is normally used because explicitly-installed packages may offer optional packages, usually for non-essential features for which the user has discretion.
When reinstalling a package, though, the current installation reason is preserved by default.
The list of explicitly-installed packages can be shown with pacman -Qe , while the complementary list of dependencies can be shown with pacman -Qd .
To change the installation reason of an already installed package, execute:
Use —asexplicit to do the opposite operation.
Search for a package that contains a specific file
This article or section is a candidate for merging with pacman/Tips and tricks.
Sync the files database:
Search for a package containing a file, e.g.:
For advanced functionality, install pkgfile, which uses a separate database with all files and their associated packages.
What happens during package install/upgrade/removal
When successful, the workflow of a transaction follows five high-level steps plus pre/post transaction hooks:
- Initialize the transaction if there is not a database lock
- Choose which packages will be added or removed in the transaction
- Prepare the transaction, based on flags, by performing sanity checks on the sync databases, packages, and their dependencies
- Commit the transaction:
- When applicable, download packages ( _alpm_sync_load )
- If pre-existing pacman PreTransaction hooks apply, they are executed.
- Packages are removed that are to-be-replaced, conflicting, or explicitly targeted to be removed
- If there are packages to add, then each package is committed
- If the package has an install script, its pre_install function is executed (or pre_upgrade or pre_remove in the case of an upgraded or removed package).
- Pacman deletes all the files from a pre-existing version of the package (in the case of an upgraded or removed package). However, files that were marked as configuration files in the package are kept (see /Pacnew and Pacsave).
- Pacman untars the package and dumps its files into the file system (in the case of an installed or upgraded package). Files that would overwrite kept, and manually modified, configuration files (see previous step), are stored with a new name (.pacnew).
- If the package has an install script, its post_install function is executed (or post_upgrade or post_remove in the case of an upgraded or removed package).
- If pacman PostTransaction hooks that exist at the end of the transaction apply, they are executed.
- Release the transaction and transaction resource (i.e. database lock)
Configuration
Pacman’s settings are located in /etc/pacman.conf : this is the place where the user configures the program to work in the desired manner. In-depth information about the configuration file can be found in pacman.conf(5) .
General options
General options are in the [options] section. Read pacman.conf(5) or look in the default pacman.conf for information on what can be done here.
Comparing versions before updating
To see old and new versions of available packages, uncomment the «VerbosePkgLists» line in /etc/pacman.conf . The output of pacman -Syu will be like this:
Enabling parallel downloads
Pacman 6.0 introduced the option to download packages in parallel. ParallelDownloads under [options] needs to be set to a positive integer in /etc/pacman.conf to use this feature (e.g., 5 ). Packages will otherwise be downloaded sequentially if this option is unset.
Skip package from being upgraded
To have a specific package skipped when upgrading the system, add this line in the [options] section:
For multiple packages use a space-separated list, or use additional IgnorePkg lines. Also, glob patterns can be used. If you want to skip packages just once, you can also use the —ignore option on the command-line — this time with a comma-separated list.
It will still be possible to upgrade the ignored packages using pacman -S : in this case pacman will remind you that the packages have been included in an IgnorePkg statement.
Skip package group from being upgraded
As with packages, skipping a whole package group is also possible:
Skip file from being upgraded
All files listed with a NoUpgrade directive will never be touched during a package install/upgrade, and the new files will be installed with a .pacnew extension.
Multiple files can be specified like this:
Skip files from being installed to system
To always skip installation of specific directories list them under NoExtract . For example, to avoid installation of systemd units use this:
Later rules override previous ones, and you can negate a rule by prepending ! .
Maintain several configuration files
If you have several configuration files (e.g. main configuration and configuration with testing repository enabled) and would have to share options between configurations you may use Include option declared in the configuration files, e.g.:
where /path/to/common/settings file contains the same options for both configurations.
Hooks
Pacman can run pre- and post-transaction hooks from the /usr/share/libalpm/hooks/ directory; more directories can be specified with the HookDir option in pacman.conf , which defaults to /etc/pacman.d/hooks . Hook file names must be suffixed with .hook. Pacman hooks are not interactive.
Pacman hooks are used, for example, in combination with systemd-sysusers and systemd-tmpfiles to automatically create system users and files during the installation of packages. For example, tomcat8 specifies that it wants a system user called tomcat8 and certain directories owned by this user. The pacman hooks systemd-sysusers.hook and systemd-tmpfiles.hook invoke systemd-sysusers and systemd-tmpfiles when pacman determines that tomcat8 contains files specifying users and tmp files.
For more information on alpm hooks, see alpm-hooks(5) .
Repositories and mirrors
Besides the special [options] section, each other [section] in pacman.conf defines a package repository to be used. A repository is a logical collection of packages, which are physically stored on one or more servers: for this reason each server is called a mirror for the repository.
Repositories are distinguished between official and unofficial. The order of repositories in the configuration file matters; repositories listed first will take precedence over those listed later in the file when packages in two repositories have identical names, regardless of version number. In order to use a repository after adding it, you will need to upgrade the whole system first.
Each repository section allows defining the list of its mirrors directly or in a dedicated external file through the Include directive; for example, the mirrors for the official repositories are included from /etc/pacman.d/mirrorlist . See the Mirrors article for mirror configuration.
Package cache directory
Pacman stores downloaded package files in cache, in a directory denoted by CacheDir in [options] section of pacman.conf (defaults to /var/cache/pacman/pkg/ if not set).
Cache directory may grow over time, even if keeping just the freshest versions of installed packages.
If you want to move that directory to some more convenient place, do one of the following:
- Set the CacheDir option in pacman.conf to new directory. Remember to retain the trailing slash. This is the recommended solution.
- Mount a dedicated partition or e.g. Btrfs subvolume in /var/cache/pacman/pkg/ .
- Bind-mount selected directory in /var/cache/pacman/pkg/ .
Package security
Pacman supports package signatures, which add an extra layer of security to the packages. The default configuration, SigLevel = Required DatabaseOptional , enables signature verification for all the packages on a global level. This can be overridden by per-repository SigLevel lines. For more details on package signing and signature verification, take a look at pacman-key.
Troubleshooting
«Failed to commit transaction (conflicting files)» error
If you see the following error: [1]
This is happening because pacman has detected a file conflict, and by design, will not overwrite files for you. This is by design, not a flaw.
The problem is usually trivial to solve. A safe way is to first check if another package owns the file ( pacman -Qo /path/to/file ). If the file is owned by another package, file a bug report. If the file is not owned by another package, rename the file which ‘exists in filesystem’ and re-issue the update command. If all goes well, the file may then be removed.
If you had installed a program manually without using pacman, for example through make install , you have to remove/uninstall this program with all of its files. See also Pacman tips#Identify files not owned by any package.
Every installed package provides a /var/lib/pacman/local/package-version/files file that contains metadata about this package. If this file gets corrupted, is empty or goes missing, it results in file exists in filesystem errors when trying to update the package. Such an error usually concerns only one package. Instead of manually renaming and later removing all the files that belong to the package in question, you may explicitly run pacman -S —overwrite glob package to force pacman to overwrite files that match glob .
«Failed to commit transaction (invalid or corrupted package)» error
Look for .part files (partially downloaded packages) in /var/cache/pacman/pkg/ and remove them (often caused by usage of a custom XferCommand in pacman.conf ).
That same error may also appear if archlinux-keyring is out-of-date, preventing pacman from verifying signatures. See Pacman/Package signing#Upgrade system regularly for the fix and how to avoid it in the future.
«Failed to init transaction (unable to lock database)» error
When pacman is about to alter the package database, for example installing a package, it creates a lock file at /var/lib/pacman/db.lck . This prevents another instance of pacman from trying to alter the package database at the same time.
If pacman is interrupted while changing the database, this stale lock file can remain. If you are certain that no instances of pacman are running then delete the lock file:
Packages cannot be retrieved on installation
This error manifests as Not found in sync db , Target not found or Failed retrieving file .
Firstly, ensure the package actually exists. If certain the package exists, your package list may be out-of-date. Try running pacman -Syu to force a refresh of all package lists and upgrade. Also make sure the selected mirrors are up-to-date and repositories are correctly configured.
It could also be that the repository containing the package is not enabled on your system, e.g. the package could be in the multilib repository, but multilib is not enabled in your pacman.conf .
Pacman crashes during an upgrade
In the case that pacman crashes with a «database write» error while removing packages, and reinstalling or upgrading packages fails thereafter, do the following:
- Boot using the Arch installation media. Preferably use a recent media so that the pacman version matches/is newer than the system.
- Mount the system’s root filesystem, e.g., mount /dev/sdaX /mnt as root, and check the mount has sufficient space with df -h
- Mount the proc, sys and dev filesystems as well: mount -t proc proc /mnt/proc; mount —rbind /sys /mnt/sys; mount —rbind /dev /mnt/dev
- If the system uses default database and directory locations, you can now update the system’s pacman database and upgrade it via pacman —sysroot /mnt -Syu as root.
- Alternatively, if you cannot update/upgrade, refer to Pacman/Tips and tricks#Reinstalling all packages.
- After the upgrade, one way to double-check for not upgraded but still broken packages: find /mnt/usr/lib -size 0
- Followed by a re-install of any still broken package via pacman —sysroot /mnt -S package .
pacman: command not found
If /var/cache/pacman/pkg is a symlink, pacman will try to make a directory instead and thus remove this symlink during self-upgrade. This will cause the update to fail. As a result, /usr/bin/pacman and other contents of the pacman package will be missing.
Never symlink /var/cache/pacman/pkg because it is controlled by pacman. Use the CacheDir option or a bind mount instead; see #Package cache directory.
If you have already encountered this problem and broke your system, you can manually extract /usr contents from the package to restore pacman and then reinstall it properly; see FS#73306 and related forum thread for details.
Manually reinstalling pacman
Using pacman-static
pacman-static AUR is a statically compiled version of pacman, so it will be able to run even when the libraries on the system are not working. This can also come in handy when a partial upgrade was performed and pacman can not run anymore.
The pinned comment and the PKGBUILD provides a way to directly download the binary, which can be used to reinstall pacman or to upgrade the entire system in case of partial upgrades.
Using an external pacman
If even pacman-static does not work, it is possible to recover using an external pacman. One of the easiest methods to do so is by using the archiso and simply using —sysroot or —root to specify the mount point. See Chroot#Using chroot on how to mount the necessary filesystems required by —sysroot .
Even if pacman is terribly broken, you can fix it manually by downloading the latest packages and extracting them to the correct locations. The rough steps to perform are:
- Determine the pacman dependencies to install
- Download each package from a mirror of your choice
- Extract each package to root
- Reinstall these packages with pacman -S —overwrite to update the package database accordingly
- Do a full system upgrade
If you have a healthy Arch system on hand, you can see the full list of dependencies with:
But you may only need to update a few of them depending on your issue. An example of extracting a package is
Note the use of the w flag for interactive mode. Running non-interactively is very risky since you might end up overwriting an important file. Also take care to extract packages in the correct order (i.e. dependencies first). This forum post contains an example of this process where only a couple pacman dependencies are broken.
«Unable to find root device» error after rebooting
Most likely the initramfs became corrupted during a kernel update (improper use of pacman’s —overwrite option can be a cause). There are two options; first, try the Fallback entry.
Once the system starts, run this command (for the stock linux kernel) either from the console or from a terminal to rebuild the initramfs image:
If that does not work, from a current Arch release (CD/DVD or USB stick), mount your root and boot partitions to /mnt and /mnt/boot , respectively. Then chroot using arch-chroot:
Reinstalling the kernel (the linux package) will automatically re-generate the initramfs image with mkinitcpio -p linux . There is no need to do this separately.
Afterwards, it is recommended that you run exit , umount /mnt/ and reboot .
«Warning: current locale is invalid; using default «C» locale» error
As the error message says, your locale is not correctly configured. See Locale.
Pacman does not honor proxy settings
Make sure that the relevant environment variables ( $http_proxy , $ftp_proxy etc.) are set up. If you use pacman with sudo, you need to configure sudo to pass these environment variables to pacman. Also, ensure the configuration of dirmngr has honor-http-proxy in /etc/pacman.d/gnupg/dirmngr.conf to honor the proxy when refreshing the keys.
How do I reinstall all packages, retaining information on whether something was explicitly installed or as a dependency?
To reinstall all the native packages: pacman -Qnq | pacman -S — or pacman -S $(pacman -Qnq) (the -S option preserves the installation reason by default).
You will then need to reinstall all the foreign packages, which can be listed with pacman -Qmq .
«Cannot open shared object file» error
It looks like previous pacman transaction removed or corrupted shared libraries needed for pacman itself.
To recover from this situation, you need to unpack required libraries to your filesystem manually. First find what package contains the missed library and then locate it in the pacman cache ( /var/cache/pacman/pkg/ ). Unpack required shared library to the filesystem. This will allow to run pacman.
Now you need to reinstall the broken package. Note that you need to use —overwrite flag as you just unpacked system files and pacman does not know about it. Pacman will correctly replace our shared library file with one from package.
That’s it. Update the rest of the system.
Freeze of package downloads
Some issues have been reported regarding network problems that prevent pacman from updating/synchronizing repositories. [2] [3] When installing Arch Linux natively, these issues have been resolved by replacing the default pacman file downloader with an alternative (see Improve pacman performance for more details). When installing Arch Linux as a guest OS in VirtualBox, this issue has also been addressed by using Host interface instead of NAT in the machine properties.
Failed retrieving file ‘core.db’ from mirror
If you receive this error message with correct mirrors, try setting a different name server.
error: ‘local-package.pkg.tar’: permission denied
If you want to install a package on an sshfs mount using pacman -U and receive this error, move the package to a local directory and try to install again.
error: could not determine cachedir mount point /var/cache/pacman/pkg
Upon executing, e.g., pacman -Syu inside a chroot environment an error is encountered:
This is frequently caused by the chroot directory not being a mountpoint when the chroot is entered. See the note at Install Arch Linux from existing Linux#Downloading basic tools for a solution, and arch-chroot(8) for an explanation and an example of using bind mounting to make the chroot directory a mountpoint.
error: GPGME error: No data
If you are unable to update packages and receive this error, try rm -r /var/lib/pacman/sync/ before attempting to update.
Источник
sudo pacman -Syu
I try updating all the packages using pacman on my Manjaro Linux and pacman necessarily does everything to download the latest updates of all the available packages and after checking for file conflicts, it throws
...
(126/126) checking keys in keyring 100%
(126/126) checking package integrity 100%
(126/126) loading package files 100%
(126/126) checking for file conflicts
error: failed to commit transaction (conflicting files)
npm: /usr/lib/node_modules/npm/lib/exec/get-workspace-location-msg.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/@npmcli/git/lib/utils.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/balanced-match/.github/FUNDING.yml exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/just-diff/index.d.ts exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/just-diff/index.tests.ts exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/CHANGELOG.md exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/LICENSE exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/README.md exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/cache-install-dir.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/get-bin-from-manifest.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/index.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/manifest-missing.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/no-tty.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/lib/run-script.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/libnpmexec/package.json exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/proc-log/LICENSE exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/proc-log/README.md exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/proc-log/index.js exists in filesystem
npm: /usr/lib/node_modules/npm/node_modules/proc-log/package.json exists in filesystem
Errors occurred, no packages were upgraded.
Should I have to do anything specific for the node_modules which I assume are the globally installed node modules to be over written or something?
asked May 2, 2021 at 5:18
Removing the npm package first and then deleting node_modules directory is a workaround that I used to make this work. However, I am not sure if that is the right solution. You can do something like this before you do a full update and then install the npm back again.
$ sudo pacman -Rns npm
$ sudo rm -R /usr/lib/node_modules/npm/
$ sudo rm -R /usr/share/man/man1/
$ sudo pacman -Syyu
$ sudo pacman -S npm
answered May 2, 2021 at 5:24
1
You can sudo pacman -S npm --overwrite '/usr/lib/node_modules/npm/*'
Comment by the answer’s author:
It basically resolves conflicts by overwriting files. In your case, conflicting files are all located in
/usr/lib/node_modules/npm/
therefore the*
will match all of them. No need to delete them manually withrm -r
which would leave the package in an inconsistent state. It is good practice to update/upgrade afterward withsudo pacman -Syyu
.
prd
2,1722 gold badges17 silver badges31 bronze badges
answered May 25, 2021 at 10:27
3
Just sudo rm -fr /usr/lib/node_modules
will work too. node_modules
is where npm compiles stuff to, so just remove the compilation contents.
answered May 11, 2021 at 9:13
RickRick
4856 silver badges23 bronze badges
1
better use this ->
pacman -Syu blackarch --overwrite '*'
Tyler2P
2,28118 gold badges23 silver badges29 bronze badges
answered May 16, 2022 at 15:39
1
Brief: This beginner’s guide shows you what you can do with pacmancommands in Linux, how to use them to find new packages, install and upgrade new packages, and clean your system.
The pacman package manager is one of the main difference between Arch Linux and other major distributions like Red Hat and Ubuntu/Debian. It combines a simple binary package format with an easy-to-use build system. The aim of pacman is to easily manage packages, either from the official repositories or the user’s own builds.
If you ever used Ubuntu or Debian-based distributions, you might have used the apt-get or apt commands. Pacman is the equivalent in Arch Linux. If you just installed Arch Linux, one of the first few things to do after installing Arch Linux is to learn to use pacman commands.
In this beginner’s guide, I’ll explain some of the essential usage of the pacmand command that you should know for managing your Arch-based system.
Essential pacman commands Arch Linux users should know
Like other package managers, pacman can synchronize package lists with the software repositories to allow the user to download and install packages with a simple command by solving all required dependencies.
Install packages with pacman
You can install a single package or multiple packages using pacman command in this fashion:
pacman -S _package_name1_ _package_name2_ ...
The -S stands for synchronization. It means that pacman first synchronizes
The pacman database categorises the installed packages in two groups according to the reason why they were installed:
- explicitly-installed: the packages that were installed by a generic pacman -S or -U command
- dependencies: the packages that were implicitly installed because required by another package that was explicitly installed.
Remove an installed package
To remove a single package, leaving all of its dependencies installed:
pacman -R package_name_
To remove a package and its dependencies which are not required by any other installed package:
pacman -Rs _package_name_
To remove dependencies that are no longer needed. For example, the package which needed the dependencies was removed.
pacman -Qdtq | pacman -Rs -
Upgrading packages
Pacman provides an easy way to update Arch Linux. You can update all installed packages with just one command. This could take a while depending on how up-to-date the system is.
The following command synchronizes the repository databases and updates the system’s packages, excluding “local” packages that are not in the configured repositories:
pacman -Syu
- S stands for sync
- y is for refresh (local cache)
- u is for system update
Basically it is saying that sync to central repository (master package database), refresh the local copy of the master package database and then perform the system update (by updating all packages that have a newer version available).
Attention!
If you are an Arch Linux user before upgrading, it is advised to visit the Arch Linux home page to check the latest news for out-of-the-ordinary updates. If manual intervention is needed an appropriate news post will be made. Alternatively you can subscribe to the RSS feed or the arch-announce mailing list.
Be also mindful to look over the appropriate forum before upgrading fundamental software (such as the kernel, xorg, systemd, or glibc), for any reported problems.
Partial upgrades are unsupported at a rolling release distribution such as Arch and Manjaro. That means when new library versions are pushed to the repositories, all the packages in the repositories need to be rebuilt against the libraries. For example, if two packages depend on the same library, upgrading only one package, might break the other package which depends on an older version of the library.
Use pacman to search for packages
Pacman queries the local package database with the -Q flag, the sync database with the -S flag and the files database with the -F flag.
Pacman can search for packages in the database, both in packages’ names and descriptions:
pacman -Ss _string1_ _string2_ ...
To search for already installed packages:
pacman -Qs _string1_ _string2_ ...
To search for package file names in remote packages:
pacman -F _string1_ _string2_ ...
To view the dependency tree of a package:
pactree _package_naenter code hereme_
Cleaning the package cache
Pacman stores its downloaded packages in /var/cache/pacman/pkg/ and does not remove the old or uninstalled versions automatically. This has some advantages:
- It allows to downgrade a package without the need to retrieve the previous version through other sources.
- A package that has been uninstalled can easily be reinstalled directly from the cache folder.
However, it is necessary to clean up the cache periodically to prevent the folder to grow in size.
The paccache(8) script, provided within the pacman-contrib package, deletes all cached versions of installed and uninstalled packages, except for the most recent 3, by default:
paccache -r
To remove all the cached packages that are not currently installed, and the unused sync database, execute:
pacman -Sc
To remove all files from the cache, use the clean switch twice, this is the most aggressive approach and will leave nothing in the cache folder:
pacman -Scc
Installing local or third-party packages
Install a ‘local’ package that is not from a remote repository:
pacman -U _/path/to/package/package_name-version.pkg.tar.xz_
Install a ‘remote’ package, not contained in an official repository:
pacman -U http://www.example.com/repo/example.pkg.tar.xz
Bonus: Troubleshooting common errors with pacman
Here are some common errors you may encounter while managing packages with pacman.
Failed to commit transaction (conflicting files)
If you see the following error:
error: could not prepare transaction
error: failed to commit transaction (conflicting files)
package: /path/to/file exists in filesystem
Errors occurred, no packages were upgraded.
This is happening because pacman has detected a file conflict and will not overwrite files for you.
A safe way to solve this is to first check if another package owns the file (pacman -Qo /path/to/file). If the file is owned by another package, file a bug report. If the file is not owned by another package, rename the file which ‘exists in filesystem’ and re-issue the update command. If all goes well, the file may then be removed.
Instead of manually renaming and later removing all the files that belong to the package in question, you may explicitly run pacman -S –overwrite glob package to force pacman to overwrite files that match glob.
Failed to commit transaction (invalid or corrupted package)
Look for .part files (partially downloaded packages) in /var/cache/pacman/pkg/ and remove them. It is often caused by usage of a custom XferCommand in pacman.conf.
Failed to init transaction (unable to lock database)
When pacman is about to alter the package database, for example installing a package, it creates a lock file at /var/lib/pacman/db.lck. This prevents another instance of pacman from trying to alter the package database at the same time.
If pacman is interrupted while changing the database, this stale lock file can remain. If you are certain that no instances of pacman are running then delete the lock file.
Check if a process is holding the lock file:
lsof /var/lib/pacman/db.lck
If the above command doesn’t return anything, you can remove the lock file:
rm /var/lib/pacman/db.lck
If you find the PID of the process holding the lock file with lsof command output, kill it first and then remove the lock file.
I hope you like my humble effort in explaining the basic pacman commands. Please leave your comments below and don’t forget to subscribe on our social media. Stay safe!