Gentoo Wiki


This article is part of the MAN series.
Purge this man page to update its contents




emerge - Command-line interface to the Portage system



[options] [action] [ebuild | tbz2file | set | atom] ...

--sync | --version

--info [atom]

--search somestring

--help [system | world | --sync]


emerge is the definitive command-line interface to the Portage system. It is primarily used for installing packages, and emerge can automatically handle any dependencies that the desired package has. emerge can also update the portage tree, making new and updated packages available. emerge gracefully handles updating installed packages to newer releases as well. It handles both source and binary packages, and it can be used to create binary packages for distribution.


emerge primarily installs packages. You can specify packages to install in one of four main ways: an ebuild, a tbz2file, a set, or an atom.


An ebuild must be, at a minimum, a valid Portage package directory name without a version or category, such as portage or python. Both categories and version numbers may be used in addition, such as sys-apps/portage or =python-2.2.1-r2. emerge ignores a trailing slash so that filename completion can be used. The ebuild may also be an actual filename, such as /usr/portage/app-admin/python/python-2.2.1-r2.ebuild. WARNING: The implementation of emerge /path/to/ebuild is broken and so this syntax shouldn't be used.

A tbz2file must be a valid .tbz2 created with ebuild <package>-<version>.ebuild package or emerge --buildpkg [category/]<package> or quickpkg /var/db/pkg/<category>/<package>.

A set is a convenient shorthand for a large group of packages. Two sets are currently supported: system and world. system refers to a set of packages deemed necessary for your system to run properly. world contains all the packages in system, plus any other packages listed in /var/lib/portage/world. [See FILES below for more information.] Note that a set is generally used in conjunction with --update.

An atom describes bounds on a package that you wish to install. >=dev-lang/python-2.2.1-r2 matches the latest available version of Python greater than or equal to 2.2.1-r2. Similarly, <dev-lang/python-2.0 matches the latest available version of Python before 2.0. Note that in many shells you will need to escape characters such as '<' and '='; use single- or double-quotes around the atom to get around escaping problems.


No action

If no action is specified, the action is to merge in the specified packages, satisfying any dependencies that they may have. The arguments can be ebuilds, tbz2s, sets, or atoms. Note that you need to use the --usepkg option if you want to install a tbz2. The packages are added to the world file at the end, so that they are considered for later updating.
--clean (-c)

Cleans up the system by examining the installed packages and removing older packages. This is accomplished by looking at each installed package and separating the installed versions by slot. Clean will remove all but the most recently installed version in each slot. Clean should not remove unslotted packages. Note: Most recently installed means most recent, not highest version.

Run package specific actions needed to be executed after the emerge process has completed. This usually entails configuration file setup or other similar setups that the user may wish to run.

Cleans the system by removing packages that are not associated with explicitly merged packages. Depclean works by creating the full dependency tree from the system list and the world file, then comparing it to installed packages. Packages installed, but not associated with an explicit merge are listed as candidates for unmerging. Inexperienced users are advised to use --pretend with this option in order to see a preview of which packages will be uninstalled. WARNING: Removing some packages may cause packages which link to the removed package to stop working and complain about missing libraries. Rebuild the complaining package to fix this issue. Also see --with-bdeps for behavior with respect to build time dependencies that are not strictly required. Depclean serves as a dependency aware version of --unmerge. When given one or more atoms, it will unmerge matched packages that have no reverse dependencies. Use --depclean together with --verbose to show reverse dependencies.
--help (-h)

Displays help information for emerge. Adding one of the additional arguments listed above will give you more specific help information on that subject. The internal emerge help documentation is updated more frequently than this man page; check it out if you are having problems that this man page does not help resolve.

Produces a list of information to include in bug reports which aids the developers when fixing the reported problem. Please include this information when submitting a bug report. Expanded output can be obtained with the --verbose option.

Transfers metadata cache from ${PORTDIR}/metadata/cache/ to /var/cache/edb/dep/ as is normally done on the tail end of an rsync update using emerge --sync. This process populates the cache database that portage uses for pre-parsed lookups of package data. It does not populate cache for the overlays listed in PORTDIR_OVERLAY. In order to generate cache for overlays, use --regen.
--prune (-P)

WARNING: This action can remove important packages! Removes all but the highest installed version of a package from your system. This action doesn't verify the possible binary compatibility between versions and can thus remove essential dependencies from your system. Use --prune together with --verbose to show reverse dependencies or with --nodeps to ignore all dependencies.

Causes portage to check and update the dependency cache of all ebuilds in the portage tree. The cache is used to speed up searches and the building of dependency trees. This command is not recommended for rsync users as rsync updates the cache using server-side caches. If you do not know the differences between a 'rsync user' and some other user, then you are a 'rsync user' :). Rsync users should simply run emerge --sync to regenerate the cache. After a portage update, rsync users may find it convenient to run emerge --metadata to rebuild the cache as portage does at the end of a sync operation.

Resumes the most recent merge list that has been aborted due to an error. Please note that this operation will only return an error on failure. If there is nothing for portage to do, then portage will exit with a message and a success condition. A resume list will persist until it has been completed in entirety or until another aborted merge list replaces it. The resume history is capable of storing two merge lists. After one resume list completes, it is possible to invoke --resume once again in order to resume an older list.
--search (-s)

Searches for matches of the supplied string in the portage tree. By default emerge uses a case-insensitive simple search, but you can enable a regular expression search by prefixing the search string with %. For example, emerge --search "%^kde" searches for any package whose name starts with "kde"; emerge --search "%gcc$" searches for any package that ends with "gcc"; emerge --search "office" searches for any package that contains the word "office". If you want to include the category into the search string, prepend an @: emerge --search "%@^dev-java.*jdk". If you want to search the package descriptions as well, use the --searchdesc action.
--searchdesc (-S)

Matches the search string against the description field as well as the package name. Take caution as the descriptions are also matched as regular expressions.

Initiates a portage tree update with one of the mirrors. Note that any changes you have made to the portage tree will be erased. Except for special circumstances, description of PORTDIR_OVERLAY for a method to avoid deletions.
--unmerge (-C)

WARNING: This action can remove important packages! Removes all matching packages. This does no checking of dependencies, so it may remove packages necessary for the proper operation of your system. Its arguments can be atoms or ebuilds. For a dependency aware version of --unmerge, use --depclean or --prune.
--update (-u)

Updates packages to the best version available, which may not always be the highest version number due to masking for testing and development. This will also update direct dependencies which may not be what you want. Package atoms specified on the command line are greedy, meaning that unspecific atoms may match multiple installed versions of slotted packages.
--version (-V)

Displays the version number of emerge.



When displaying USE and other flag output, combines the enabled and disabled lists into one list and sorts the whole list alphabetically.
--ask (-a)

Before performing the action, display what will take place (server info for --sync, --pretend output for merge, and so forth), then ask whether to proceed with the action or abort. Using --ask is more efficient than using --pretend and then executing the same command without --pretend, as dependencies will only need to be calculated once. WARNING: If the "Enter" key is pressed at the prompt (with no other input), it is interpreted as acceptance of the first choice. Note that the input buffer is not cleared prior to the prompt, so an accidental press of the "Enter" key at any time prior to the prompt will be interpreted as a choice!
--buildpkg (-b)

Tells emerge to build binary packages for all ebuilds processed in addition to actually merging the packages. Useful for maintainers or if you administrate multiple Gentoo Linux systems (build once, emerge tbz2s everywhere) as well as disaster recovery. The package will be created in the ${PKGDIR}/All directory. An alternative for already-merged live filesystem.
--buildpkgonly (-B)

Creates binary packages for all ebuilds processed without actually merging the packages. This comes with the caveat that all build-time dependencies must already be emerged on the system.
--changelog (-l)

Use this in conjunction with the --pretend option. This will show the ChangeLog entries for all the packages that will be upgraded.
--color < y | n >

Enable or disable color output. This option will override NOCOLOR is not a tty (by default, color is disabled unless stdout is a tty).

Used alongside --pretend to cause the package name, new version, and old version to be displayed in an aligned format for easy cut-n-paste.

Set the PORTAGE_CONFIGROOT environment variable.
--debug (-d)

Tells emerge to run the emerge command in --debug mode. In this mode the bash build environment will run with the -x option, causing it to output verbose debugging information to stdout. This also enables a plethora of other output (mostly dependency resolution messages).
--deep (-D)

This flag forces emerge to consider the entire dependency tree of packages, instead of checking only the immediate dependencies of the packages. As an example, this catches updates in libraries that are not directly listed in the dependencies of a package. Also see --with-bdeps for behavior with respect to build time dependencies that are not strictly required.
--emptytree (-e)

Reinstalls all world packages and their dependencies to the current USE specifications while differing from the installed set of packages as little as possible. You should run with --pretend first to make sure the result is what you expect.
--fetchonly (-f)

Instead of doing any package building, just perform fetches for all packages (fetch things from SRC_URI based upon USE setting).
--fetch-all-uri (-F)

Instead of doing any package building, just perform fetches for all packages (fetch everything in SRC_URI irregardless of USE setting).
--getbinpkg (-g)

Using the server and location defined in PORTAGE_BINHOST (see package found and it will use that information to help build the dependency list. This option implies -k. (Use -gK for binary-only merging.)
--getbinpkgonly (-G)

This option is identical to -g, as above, except it will not use ANY information from the local machine. All binaries will be downloaded from the remote server without consulting packages existing in the local packages directory.

--newuse (-N)

Tells emerge to include installed packages where USE flags have changed since compilation. USE flag changes include:

A USE flag was added to a package. A USE flag was removed from a package. A USE flag was turned on for a package. A USE flag was turned off for a package.

USE flags may be toggled by your profile as well as your USE and package.use settings.


Causes portage to disregard merge records indicating that a config file inside of a CONFIG_PROTECT directory has been merged already. Portage will normally merge those files only once to prevent the user from dealing with the same config multiple times. This flag will cause the file to always be merged.
--nodeps (-O)

Merges specified packages without merging any dependencies. Note that the build may fail if the dependencies aren't satisfied.
--noreplace (-n)

Skips the packages specified on the command-line that have already been installed. Without this option, any packages, ebuilds, or deps you specify on the command-line will cause Portage to remerge the package, even if it is already installed. Note that Portage will not remerge dependencies by default.

Disables the spinner for the session. The spinner is active when the terminal device is determined to be a TTY. This flag disables it regardless.
--oneshot (-1)

Emerge as normal, but do not add the packages to the world file for later updating.
--onlydeps (-o)

Only merge (or pretend to merge) the dependencies of the packages specified, not the packages themselves.
--pretend (-p)

Instead of actually performing the merge, simply display what *would* have been installed if --pretend weren't used. Using --pretend is strongly recommended before installing an unfamiliar package. In the printout:


N = new (not yet installed)

S = new SLOT installation (side-by-side versions)

U = updating (to another version)

D = downgrading (best version seems lower)

R = replacing (remerging same version))

F = fetch restricted (must be manually downloaded)

f = fetch restricted (already downloaded)

B = blocked by an already installed package

--quiet (-q)

Results may vary, but the general outcome is a reduced or condensed output from portage's displays.
--reinstall changed-use

Tells emerge to include installed packages where USE flags have changed since installation. Unlike --newuse, this option does not trigger reinstallation when flags that the user has not enabled are added or removed.

This option is only valid when used with --resume. It removes the first package in the resume list so that a merge may continue in the presence of an uncorrectable or inconsequential error. This should only be used in cases where skipping the package will not result in failed dependencies.
--tree (-t)

Shows the dependency tree for the given target by indenting dependencies. This is only really useful in combination with --emptytree or --update and --deep.
--usepkg (-k)

Tells emerge to use binary packages (from $PKGDIR) if they are available, thus possibly avoiding some time-consuming compiles. This option is useful for CD installs; you can export PKGDIR=/mnt/cdrom/packages and then use this option to have emerge "pull" binary packages from the CD in order to satisfy dependencies.
--usepkgonly (-K)

Tells emerge to only use binary packages (from $PKGDIR). All the binary packages must be available at the time of dependency calculation or emerge will simply abort. Portage does not use $PORTDIR when calculating dependency information so all masking information is ignored.
--verbose (-v)

Tell emerge to run in verbose mode. Currently this flag causes emerge to print out GNU info errors, if any, and to show the USE flags that will be used for each package when pretending. The following symbols are affixed to USE flags in order to indicate their status:

- prefix = not enabled (either disabled or removed)

* suffix = transition to or from the enabled state

% suffix = newly added or removed

() circumfix = forced, masked, or removed

--with-bdeps < y | n >

In dependency calculations, pull in build time dependencies that are not strictly required. This defaults to 'n' for installation actions and 'y' for the --depclean action. This setting can be added to command line.


ROOT = [path]
Use ROOT to specify the target root filesystem to be used for when PORTAGE_CONFIGROOT has a value other than /.

Defaults to /.

Use PORTAGE_CONFIGROOT to specify the location for various portage configuration files (see FILES for a detailed list of configuration files). This variable can be set via the --config-root option.

Defaults to /.


When utilizing emerge with the --pretend and --verbose flags, the output may be a little hard to understand at first. This section explains the abbreviations.

[blocks B ] app-text/dos2unix (from pkg app-text/hd2u-0.8.0)

Dos2unix is Blocking hd2u from being emerged. Blockers are defined when two packages will clobber each others files, or otherwise cause some form of breakage in your system. However, blockers usually do not need to be simultaneously emerged because they usually provide the same functionality.
[ebuild N ] app-games/qstat-25c

Qstat is New to your system, and will be emerged for the first time.
[ebuild NS ] dev-libs/glib-2.4.7

You already have a version of glib installed, but a 'new' version in a different SLOT is available.
[ebuild R ] sys-apps/sed-4.0.5

Sed 4.0.5 has already been emerged, but if you run the command, then portage will Re-emerge the specified package (sed in this case).
[ebuild F ] media-video/realplayer-8-r6

The realplayer package requires that you Fetch the sources manually. When you attempt to emerge the package, if the sources are not found, then portage will halt and you will be provided with instructions on how to download the required files.
[ebuild f ] media-video/realplayer-8-r6

The realplayer package's files are already downloaded.
[ebuild U ] net-fs/samba-2.2.8_pre1 [2.2.7a]

Samba 2.2.7a has already been emerged and can be Updated to version 2.2.8_pre1.
[ebuild UD] media-libs/libgd-1.8.4 [2.0.11]

Libgd 2.0.11 is already emerged, but if you run the command, then portage will Downgrade to version 1.8.4 for you.

This may occur if a newer version of a package has been masked because it is broken or it creates a security risk on your system and a fix has not been released yet.

Another reason this may occur is if a package you are trying to emerge requires an older version of a package in order to emerge successfully. In this case, libgd 2.x is incompatible with libgd 1.x. This means that packages that were created with libgd 1.x will not compile with 2.x and must downgrade libgd first before they can emerge.

[ebuild U ] sys-devel/distcc-2.16 [2.13-r1] USE=ipv6* -gtk -qt%

Here we see that the make.conf variable USE affects how this package is built. In this example, ipv6 optional support is enabled and both gtk and qt support are disabled. The asterisk following ipv6 indicates that ipv6 support was disabled the last time this packages was installed. The percent sign following qt indicates that the qt option has been added to the package since it was last installed. For information about all USE symbols, see the --verbose option documentation above.

*Note: Flags that haven't changed since the last install are only displayed when you use the --pretend and --verbose options. Using the --quiet option will prevent all information from being displayed.


You should almost always precede any package install or update attempt with a --pretend install or update. This lets you see how much will be done, and shows you any blocking packages that you will have to rectify. This goes doubly so for the system and world sets, which can update a large number of packages if the portage tree has been particularly active.

You also want to typically use --update, which ignores packages that are already fully updated but updates those that are not.

When you install a package with uninstalled dependencies and do not explicitly state those dependencies in the list of parameters, they will not be added to the world file. If you want them to be detected for world updates, make sure to explicitly list them as parameters to emerge.

USE variables may be specified on the command line to override those specified in the default locations, letting you avoid using some dependencies you may not want to have. USE flags specified on the command line are NOT remembered. For example, env USE="-X -gnome" emerge mc will emerge mc with those USE settings (on Bourne-compatible shells you may omit the env part). If you want those USE settings to be more permanent, you can put them in /etc/portage/package.use instead.

If emerge --update system or emerge --update world fails with an error message, it may be that an ebuild uses some newer feature not present in this version of emerge. You can use emerge --update portage to upgrade to the lastest version, which should support any necessary new features.


NOTE: Please use caution when using development packages. Problems and bugs resulting from misusing masked packages drains Gentoo developer time. Please be sure you are capable of handling any problems that may ensue.

Masks in portage have many uses: they allow a testing period where the packages can be used in live machines; they prevent the use of a package when it will fail; and they mask existing packages that are broken or could pose a security risk. Read below to find out how to unmask in various cases. Also note that if you give emerge an ebuild, then all forms of masking will be ignored and emerge will attempt to emerge the package.


The package.mask file primarily blocks the use of packages that cause problems or are known to have issues on different systems. It resides in /usr/portage/profiles.

that have been built with a different CHOST setting. The only way to unmask such a binary package is to change the CHOST environment variable so that it exactly matches that of the binary package.

that are not supported by the current version of portage. Packages masked by EAPI can only be installed after portage has been upgraded.

The KEYWORDS variable in an ebuild file is also used for masking a package still in testing. There are architecture-specific keywords for each package that let portage know which systems are compatible with the package. Packages which compile on an architecture, but have not been proven to be "stable", are masked with a tilde (~) in front of the architecture name. emerge examines the ACCEPT_KEYWORDS environment variable to allow or disallow the emerging of a package masked by KEYWORDS. To inform emerge that it should build these 'testing' versions of packages, you should update your /etc/portage/package.keywords file to list the packages you want the


Portage has a special feature called "config file protection". The purpose of this feature is to prevent new package installs from clobbering existing configuration files. By default, config file protection is turned on for /etc and the KDE configuration dirs; more may be added in the future.

When Portage installs a file into a protected directory tree like /etc, any existing files will not be overwritten. If a file of the same name already exists, Portage will change the name of the to-be-installed file from 'foo' to '._cfg0000_foo'. If '._cfg0000_foo' already exists, this name becomes '._cfg0001_foo', etc. In this way, existing files are not overwritten, allowing the administrator to manually merge the new config files and avoid any unexpected changes.

In addition to protecting overwritten files, Portage will not delete any files from a protected directory when a package is unmerged. While this may be a little bit untidy, it does prevent potentially valuable config files from being deleted, which is of paramount importance.

Protected directories are set using the CONFIG_PROTECT variable, normally defined in /etc/make.globals. Directory exceptions to the CONFIG_PROTECTed directories can be specified using the CONFIG_PROTECT_MASK variable. To find files that need to be updated in /etc, type find /etc -iname '._cfg????_*'.

You can disable this feature by setting CONFIG_PROTECT="-*" in /etc/make.conf. Then, Portage will mercilessly auto-update your config files. Alternatively, you can leave Config File Protection on but tell Portage that it can overwrite files in certain specific /etc subdirectories. For example, if you wanted Portage to automatically update your rc scripts and your wget configuration, but didn't want any other changes made without your explicit approval, you'd add this to /etc/make.conf:

CONFIG_PROTECT_MASK=/etc/wget /etc/rc.d

Tools such as dispatch-conf, cfg-update, and etc-update are also available to aid in the merging of these files. They provide interactive merging and can auto-merge trivial changes.


Please report any bugs you encounter through our website:

Please include the output of emerge --info when you submit your bug report.


Daniel Robbins <>
Geert Bevin <>
Achim Gottinger <>
Nicholas Jones <>
Phil Bordelon <>
Mike Frysinger <>
Marius Mauch <>


Here is a common list of files you will probably be interested in. For a


Contains a list of all user-specified packages. You can safely edit this file, adding packages that you want to be considered in world set updates and removing those that you do not want to be considered.

Contains variables for the build process, overriding those in make.globals.

Contains variables customizing colors.

Contains settings to handle automatic updates/backups of configuration files.

Contains profile-specific variables for the build process. Do not edit this file.

Contains a list of packages which, if installed, cause the respective USE flag to be enabled by default. Do not edit this file.

Contains the master list of USE flags with descriptions of their functions. Do not edit this file.

Contains a list of default packages used to resolve virtual dependencies. Do not edit this file.

Contains a list of packages used for the base system. The system and world sets consult this file. Do not edit this file.

Contains the default variables for the build process. Do not edit this file.


emerge --help,






A number of helper applications reside in /usr/lib/portage/bin.

The app-portage/gentoolkit package contains useful scripts such as equery (a package query tool).

Retrieved from ""

Last modified: Wed, 08 Oct 2008 20:00:00 +0000 Hits: 174,838