stack-2.14.0: The Haskell Tool Stack
Safe HaskellSafe-Inferred
LanguageGHC2021

Stack.GhcPkg

Description

Functions for the GHC package database.

Synopsis

Documentation

createDatabase :: (HasProcessContext env, HasTerm env) => GhcPkgExe -> Path Abs Dir -> RIO env () Source #

Create a package database in the given directory, if it doesn't exist.

findGhcPkgField Source #

Arguments

:: (HasProcessContext env, HasTerm env) 
=> GhcPkgExe 
-> [Path Abs Dir]

package databases

-> String

package identifier, or GhcPkgId

-> Text 
-> RIO env (Maybe Text) 

Get the value of a field of the package.

getGlobalDB :: (HasProcessContext env, HasTerm env) => GhcPkgExe -> RIO env (Path Abs Dir) Source #

Get the global package database

ghcPkg :: (HasProcessContext env, HasTerm env) => GhcPkgExe -> [Path Abs Dir] -> [String] -> RIO env (Either SomeException ByteString) Source #

Run the ghc-pkg executable

ghcPkgPathEnvVar :: WhichCompiler -> Text Source #

Get the environment variable to use for the package DB paths.

mkGhcPackagePath :: Bool -> Path Abs Dir -> Path Abs Dir -> [Path Abs Dir] -> Path Abs Dir -> Text Source #

Get the value for GHC_PACKAGE_PATH

unregisterGhcPkgIds Source #

Arguments

:: (HasCompiler env, HasProcessContext env, HasTerm env) 
=> Bool

Report pretty exceptions as warnings?

-> GhcPkgExe 
-> Path Abs Dir

package database

-> NonEmpty (Either PackageIdentifier GhcPkgId) 
-> RIO env () 

unregister list of package ghcids, batching available from GHC 8.2.1, see https://github.com/commercialhaskell/stack/issues/2662#issuecomment-460342402 using GHC package id where available (from GHC 7.9)

The version of the ghc-pkg executable supplied with GHCs published before 28 August 2023 does not efficiently bulk unregister. Until an efficient ghc-pkg is available, this function no longer uses:

  eres <- ghcPkg pkgexe [pkgDb] args
where
   args = "unregister" : "--user" : "--force" :
     map packageIdentifierString idents ++
     if null gids then [] else "--ipid" : map ghcPkgIdString gids

but uses:

  globalDb <- view $ compilerPathsL.to cpGlobalDB
  eres <- tryAny $ liftIO $
    ghcPkgUnregisterUserForce globalDb pkgDb hasIpid pkgarg_strs