Commit 36637914 authored by Edward Z. Yang's avatar Edward Z. Yang

Disable ghc-pkg accepting multiple package IDs (differing package keys) for now.

Duncan requested that ghc-pkg not accept duplicate package IDs (foo-0.1)
by default until the higher level tools can accommodate it.  Until then
you'll need to use the --multi-instance flag to install multiple copies in
the package database.

I think reusing the --multi-instance flag is dodgy, because that can be used
to cause duplicate package keys; but there is a mode of use of the database
where package keys are unique.
Signed-off-by: default avatarEdward Z. Yang <>
parent 66218d15
......@@ -901,13 +901,13 @@ registerPackage input verbosity my_flags auto_ghci_libs multi_instance
-- In the normal mode, we only allow one version of each package, so we
-- remove all instances with the same source package key as the one we're
-- remove all instances with the same source package id as the one we're
-- adding. In the multi instance mode we don't do that, thus allowing
-- multiple instances with the same source package key.
-- multiple instances with the same source package id.
removes = [ RemovePackage p
| not multi_instance,
p <- packages db_to_operate_on,
packageKey p == packageKey pkg ]
sourcePackageId p == sourcePackageId pkg ]
changeDB verbosity (removes ++ [AddPackage pkg']) db_to_operate_on
......@@ -1564,14 +1564,13 @@ checkDuplicates :: PackageDBStack -> InstalledPackageInfo
-> Bool -> Bool-> Validate ()
checkDuplicates db_stack pkg multi_instance update = do
pkg_key = packageKey pkg
pkgid = sourcePackageId pkg
pkgs = packages (head db_stack)
-- Check whether this package id already exists in this DB
when (not update && not multi_instance
&& (pkg_key `elem` map packageKey pkgs)) $
&& (pkgid `elem` map sourcePackageId pkgs)) $
verror CannotForce $
"package " ++ display pkgid ++ " is already installed"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment