Make package explicitly installed in pacman

I found the answer on Arch Linux Forums

Since pacman 3.4 you can use

# pacman -D

to modify only the database. So:

# pacman -D --asexplicit <pkgs>

will make <pkgs> explicitly installed.

The pacman manpage further describes this command.


pacman -S has a --asexplicit flag that should do what you want.

For example:

> pacman -Qi mutagen            
...
Install Reason : Installed as a dependency for another package

> pacman -S --asexplicit mutagen
warning: mutagen-1.20-1 is up to date -- reinstalling
resolving dependencies...
looking for inter-conflicts...

Targets (1): mutagen-1.20-1

Total Download Size:    0.00 MB
Total Installed Size:   0.82 MB
...

> pacman -Qi mutagen
...
Install Reason : Explicitly installed

You can see that nothing was downloaded since it is already installed locally. It just flipped the "Install Reason" field.

Pacman has different --help operations depending on the operation (-S, -R, etc.). So pacman -S --help lists the --asexplicit flag as one of the available flags. --asdeps is available as well.