-
Notifications
You must be signed in to change notification settings - Fork 701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add base to cabal install --lib default env file #8903
Changes from 2 commits
e3b57e3
7acef4f
9d85d8b
3fe3de3
428b78f
b4c8c4c
90afcd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,7 +106,7 @@ import Distribution.Simple.Configure | |
( configCompilerEx ) | ||
import Distribution.Simple.Compiler | ||
( Compiler(..), CompilerId(..), CompilerFlavor(..) | ||
, PackageDBStack ) | ||
, PackageDBStack, PackageDB(..) ) | ||
import Distribution.Simple.GHC | ||
( ghcPlatformAndVersionString, getGhcAppDir | ||
, GhcImplInfo(..), getImplInfo | ||
|
@@ -123,11 +123,13 @@ import Distribution.Verbosity | |
import Distribution.Simple.Utils | ||
( wrapText, die', notice, warn | ||
, withTempDirectory, createDirectoryIfMissingVerbose | ||
, ordNub ) | ||
, ordNub, safeHead ) | ||
import Distribution.Utils.Generic | ||
( writeFileAtomic ) | ||
|
||
import qualified Data.ByteString.Lazy.Char8 as BS | ||
import Data.Ord | ||
( Down(..) ) | ||
import qualified Data.Map as Map | ||
import qualified Data.Set as S | ||
import qualified Data.List.NonEmpty as NE | ||
|
@@ -355,7 +357,10 @@ installAction flags@NixStyleFlags { extraFlags = clientInstallFlags', .. } targe | |
envFile <- getEnvFile clientInstallFlags platform compilerVersion | ||
existingEnvEntries <- | ||
getExistingEnvEntries verbosity compilerFlavor supportsPkgEnvFiles envFile | ||
packageDbs <- getPackageDbStack compilerId projectConfigStoreDir projectConfigLogsDir | ||
packageDbs' <- getPackageDbStack compilerId projectConfigStoreDir projectConfigLogsDir | ||
let validDb (SpecificPackageDB fp) = doesFileExist fp | ||
validDb _ = pure True | ||
packageDbs <- filterM validDb packageDbs' | ||
installedIndex <- getInstalledPackages verbosity compiler packageDbs progDb | ||
|
||
let | ||
|
@@ -424,7 +429,7 @@ installAction flags@NixStyleFlags { extraFlags = clientInstallFlags', .. } targe | |
unless dryRun $ | ||
if installLibs | ||
then installLibraries verbosity | ||
buildCtx compiler packageDbs envFile nonGlobalEnvEntries' | ||
buildCtx installedIndex compiler packageDbs envFile nonGlobalEnvEntries' | ||
else installExes verbosity | ||
baseCtx buildCtx platform compiler configFlags clientInstallFlags | ||
where | ||
|
@@ -687,20 +692,26 @@ installExes verbosity baseCtx buildCtx platform compiler | |
installLibraries | ||
:: Verbosity | ||
-> ProjectBuildContext | ||
-> PI.PackageIndex InstalledPackageInfo | ||
-> Compiler | ||
-> PackageDBStack | ||
-> FilePath -- ^ Environment file | ||
-> [GhcEnvironmentFileEntry] | ||
-> IO () | ||
installLibraries verbosity buildCtx compiler | ||
installLibraries verbosity buildCtx installedIndex compiler | ||
packageDbs envFile envEntries = do | ||
if supportsPkgEnvFiles $ getImplInfo compiler | ||
then do | ||
let | ||
getLatest = (=<<) (maybeToList . safeHead . snd) . take 1 . sortBy (comparing (Down . fst)) | ||
. PI.lookupPackageName installedIndex | ||
Comment on lines
+708
to
+709
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be universally useful, how about adding this function to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was hoping we could backport this into the cabal 3.10 series, which last I understood, we hoped to release just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'd need to have a fresh look at the planned fixes to make sure it's possible, but not releasing a new Cabal version would indeed be preferred. |
||
globalLatest = concat (getLatest <$> globalPackages) | ||
globalEntries = GhcEnvFilePackageId . installedUnitId <$> globalLatest | ||
baseEntries = | ||
GhcEnvFileClearPackageDbStack : fmap GhcEnvFilePackageDb packageDbs | ||
pkgEntries = ordNub $ | ||
envEntries | ||
globalEntries | ||
++ envEntries | ||
++ entriesForLibraryComponents (targetsMap buildCtx) | ||
contents' = renderGhcEnvironmentFile (baseEntries ++ pkgEntries) | ||
createDirectoryIfMissing True (takeDirectory envFile) | ||
|
@@ -711,6 +722,10 @@ installLibraries verbosity buildCtx compiler | |
++ "so only executables will be available. (Library installation is " | ||
++ "supported on GHC 8.0+ only)" | ||
|
||
|
||
globalPackages :: [PackageName] | ||
globalPackages = mkPackageName <$> [ "base" ] | ||
Comment on lines
+730
to
+731
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should add here a reason why we unconditionally add "base". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And not any other built-in package or whatever the smallest enclosing set is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. follow-up in #8938 |
||
|
||
warnIfNoExes :: Verbosity -> ProjectBuildContext -> IO () | ||
warnIfNoExes verbosity buildCtx = | ||
when noExes $ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this (
filterM validDb
) is the right thing to do, but this line may not be the right place to do this. Assuming that the creation of cabal-install's package database is done in the build step (lines 419--420), in the execution which creates the database, the listpackageDbs
holds fewer than we need it to. My speculation might be a total mistake, though, because I haven't looked deep down into the implementation ofrunProjectBuildPhase
. Anyway, whether or not my assumption is correct,packageDbs <- filterM vaildDb packageDbs
should be placed after the creation of the database.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the implementation of
validDb
is incorrect because a package DB is a directory (I'm not sure it is specified to be a directory, but it was one when I ran a debug). It should be:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the two points above are actually (at least) a part of the cause of the problem. See the following shell session:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the careful investigation! Both issues seem legit and I'll try to do some more work in the next few days...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed both issues raised and tested to ensure they covered the problem. Thanks again!