Opened 12 years ago

Closed 11 years ago

Last modified 15 months ago

#2441 closed bug (fixed)

Ghc-pkg cannot unregister/expose/hide packages in non-first package databases

Reported by: batterseapower Owned by: simonmar
Priority: normal Milestone: 6.10.1
Component: Build System (make) Version: 6.9
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


I was in this situation:

$ ghc-pkg list
    Cabal-, Cabal-1.5.1, Finance-Quote-Yahoo-0.4.1,
    GLUT-, HTTP-3001.0.4, HTTP-Simple-0.1, HUnit-,
    OpenAL-, QuickCheck-, array-, base-,
    binary-0.4.1, bytestring-, cgi-3001.1.5.1,
    containers-, directory-, fgl-,
    filepath-, (ghc-6.8.2), haskell-src-,
    haskell98-, hpc-, html-, hxt-7.4, mtl-,
    network-, old-locale-, old-time-,
    packedstring-, parallel-, parsec-,
    plugins-1.0, plugins-1.1, pretty-, process-,
    random-, readline-, regex-base-,
    regex-compat-, regex-posix-, rts-1.0, stm-,
    template-haskell-, time-, unix-,
    xhtml-3000.0.2.1, zlib-
    Cabal-, GLUT-, HDBC-1.1.4, MaybeT-0.1.1,
    MonadRandom-0.1.1, OpenGL-, Stream-0.2.3, arrows-0.4,
    category-extras-0.53.4, haddock-2.1.0

And from there I can do this:

$ ../../../../ghc.plugins/utils/ghc-pkg/ghc-pkg-inplace describe pan-plugin-annotations
name: pan-plugin-annotations
version: 1.0
license: BSD3
copyright: (c) Sean Seefried 2008
stability: stable

But not this!

$ ../../../../ghc.plugins/utils/ghc-pkg/ghc-pkg-inplace expose pan-plugin-annotations-1.0
ghc-pkg-inplace: cannot find package pan-plugin-annotations-1.0

Or this:

$ ../../../../ghc.plugins/utils/ghc-pkg/ghc-pkg-inplace hide pan-plugin-annotations-1.0
ghc-pkg-inplace: cannot find package pan-plugin-annotations-1.0

The reason is that ghc-pkgs modifyPackage function only looks in the FIRST package database in the list. In my opinion, it should look in all databases and either:

  1. Perform the modification requested by the user to the first database that contains the relevant package
  1. Show a smart error message indicating to the user that they need to use some flags to bring that package to the front of the package stack if they want to do that, rather than just saying "not found"

I've attached a patch that implements behaviour 1.

Attachments (1)

FixHideExposeRegisterForNonFirstPackageDB.patch (61.3 KB) - added by batterseapower 12 years ago.
Patch implementing behaviour 1

Download all attachments as: .zip

Change History (8)

Changed 12 years ago by batterseapower

Patch implementing behaviour 1

comment:1 Changed 12 years ago by duncan

Similarly we notice in #haskell that frequently people are very confused by ghc-plg list saying that a package is installed but then unregistering fails (because they do not understand the --user issue). This confusion is on the rise because cabal-install now does per-user installs by default which means there are more people with per-user packages registered and since they never had to use the --user flag in the first place they are unaware of the whole concept of global vs user package dbs..

Either different default behaviour or a better error message would be an improvement. For example at least the error message should note that the package is in the --user db and that if they should use that flag.

comment:2 Changed 12 years ago by simonmar

difficulty: Unknown
Milestone: 6.10.1

comment:3 Changed 11 years ago by simonmar

Owner: set to simonmar

comment:4 Changed 11 years ago by simonmar

Resolution: fixed
Status: newclosed

Fixed. I modified the submitted patch to do the right thing, and fixed up some other bogosity that I found along the way. Also I added a test to the testsuite.

Thu Aug 14 13:53:48 BST 2008  Simon Marlow <>
  * Fix #2441 (unregister/expose/hide packages in non-first package databases)

comment:5 Changed 11 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:6 Changed 11 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:7 Changed 15 months ago by bgamari

Component: Build SystemBuild System (make)
Type of failure: None/Unknown

The new Hadrian build system has been merged. Relabeling the tickets concerning the legacy make build system to prevent confusion.

Note: See TracTickets for help on using tickets.