Skip to content

Commit b37d3b5

Browse files
gbazKleidukos
authored andcommitted
Fix precedence for PATH for build-tools-depends
1 parent a191f0a commit b37d3b5

File tree

4 files changed

+65
-36
lines changed

4 files changed

+65
-36
lines changed

Cabal/src/Distribution/Simple/Configure.hs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,10 +1028,17 @@ mkProgramDb cfg initialProgramDb = programDb
10281028
. setProgramSearchPath searchpath
10291029
$ initialProgramDb
10301030
searchpath =
1031-
map
1032-
ProgramSearchPathDir
1033-
(fromNubList $ configProgramPathExtra cfg)
1034-
++ getProgramSearchPath initialProgramDb
1031+
getProgramSearchPath initialProgramDb
1032+
++ map
1033+
ProgramSearchPathDir
1034+
(fromNubList $ configProgramPathExtra cfg)
1035+
1036+
-- Note. We try as much as possible to _prepend_ rather than postpend the extra-prog-path
1037+
-- so that we can override the system path. However, in a v2-build, at this point, the "system" path
1038+
-- has already been extended by both the built-tools-depends paths, as well as the program-path-extra
1039+
-- so for v2 builds adding it again is entirely unnecessary. However, it needs to get added again _anyway_
1040+
-- so as to take effect for v1 builds or standalone calls to Setup.hs
1041+
-- In this instance, the lesser evil is to not allow it to override the system path.
10351042

10361043
-- -----------------------------------------------------------------------------
10371044
-- Helper functions for configure

cabal-install/src/Distribution/Client/Check.hs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -99,34 +99,35 @@ check verbosity = do
9999

100100
-- Poor man’s “group checks by constructor”.
101101
groupChecks :: [PackageCheck] -> [NE.NonEmpty PackageCheck]
102-
groupChecks ds = NE.groupBy (F.on (==) constInt)
103-
(L.sortBy (F.on compare constInt) ds)
104-
where
105-
constInt :: PackageCheck -> Int
106-
constInt (PackageBuildImpossible {}) = 0
107-
constInt (PackageBuildWarning {}) = 1
108-
constInt (PackageDistSuspicious {}) = 2
109-
constInt (PackageDistSuspiciousWarn {}) = 3
110-
constInt (PackageDistInexcusable {}) = 4
102+
groupChecks ds =
103+
NE.groupBy
104+
(F.on (==) constInt)
105+
(L.sortBy (F.on compare constInt) ds)
106+
where
107+
constInt :: PackageCheck -> Int
108+
constInt (PackageBuildImpossible{}) = 0
109+
constInt (PackageBuildWarning{}) = 1
110+
constInt (PackageDistSuspicious{}) = 2
111+
constInt (PackageDistSuspiciousWarn{}) = 3
112+
constInt (PackageDistInexcusable{}) = 4
111113

112114
groupExplanation :: PackageCheck -> String
113-
groupExplanation (PackageBuildImpossible {}) = "The package will not build sanely due to these errors:"
114-
groupExplanation (PackageBuildWarning {}) = "The following errors are likely to affect your build negatively:"
115-
groupExplanation (PackageDistSuspicious {}) = "These warnings will likely cause trouble when distributing the package:"
116-
groupExplanation (PackageDistSuspiciousWarn {}) = "These warnings may cause trouble when distributing the package:"
117-
groupExplanation (PackageDistInexcusable {}) = "The following errors will cause portability problems on other environments:"
115+
groupExplanation (PackageBuildImpossible{}) = "The package will not build sanely due to these errors:"
116+
groupExplanation (PackageBuildWarning{}) = "The following errors are likely to affect your build negatively:"
117+
groupExplanation (PackageDistSuspicious{}) = "These warnings will likely cause trouble when distributing the package:"
118+
groupExplanation (PackageDistSuspiciousWarn{}) = "These warnings may cause trouble when distributing the package:"
119+
groupExplanation (PackageDistInexcusable{}) = "The following errors will cause portability problems on other environments:"
118120

119121
groupOutputFunction :: PackageCheck -> Verbosity -> String -> IO ()
120-
groupOutputFunction (PackageBuildImpossible {}) ver = warnError ver
121-
groupOutputFunction (PackageBuildWarning {}) ver = warnError ver
122-
groupOutputFunction (PackageDistSuspicious {}) ver = warn ver
123-
groupOutputFunction (PackageDistSuspiciousWarn {}) ver = warn ver
124-
groupOutputFunction (PackageDistInexcusable {}) ver = warnError ver
122+
groupOutputFunction (PackageBuildImpossible{}) ver = warnError ver
123+
groupOutputFunction (PackageBuildWarning{}) ver = warnError ver
124+
groupOutputFunction (PackageDistSuspicious{}) ver = warn ver
125+
groupOutputFunction (PackageDistSuspiciousWarn{}) ver = warn ver
126+
groupOutputFunction (PackageDistInexcusable{}) ver = warnError ver
125127

126128
outputGroupCheck :: Verbosity -> NE.NonEmpty PackageCheck -> IO ()
127129
outputGroupCheck ver pcs = do
128-
let hp = NE.head pcs
129-
outf = groupOutputFunction hp ver
130-
notice ver (groupExplanation hp)
131-
CM.mapM_ (outf . ppPackageCheck) pcs
132-
130+
let hp = NE.head pcs
131+
outf = groupOutputFunction hp ver
132+
notice ver (groupExplanation hp)
133+
CM.mapM_ (outf . ppPackageCheck) pcs

cabal-install/src/Distribution/Client/ProjectPlanning.hs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,9 @@ sanityCheckElaboratedPackage
347347
-- readProjectConfig also loads the global configuration, which is read with
348348
-- loadConfig and convertd to a ProjectConfig with convertLegacyGlobalConfig.
349349
--
350-
-- *Important*
350+
351+
-- * Important *
352+
351353
--
352354
-- You can notice how some project config options are needed to read the
353355
-- project config! This is evident by the fact that rebuildProjectConfig
@@ -539,9 +541,10 @@ configureCompiler
539541
)
540542
$ defaultProgramDb
541543

542-
543544
------------------------------------------------------------------------------
545+
544546
-- * Deciding what to do: making an 'ElaboratedInstallPlan'
547+
545548
------------------------------------------------------------------------------
546549

547550
-- | Return an up-to-date elaborated install plan.
@@ -4000,7 +4003,7 @@ setupHsScriptOptions
40004003
, usePackageIndex = Nothing
40014004
, useDependencies =
40024005
[ (uid, srcid)
4003-
| (ConfiguredId srcid (Just (CLibName LMainLibName)) uid, _) <-
4006+
| ConfiguredId srcid (Just (CLibName LMainLibName)) uid <-
40044007
elabSetupDependencies elab
40054008
]
40064009
, useDependenciesExclusive = True
@@ -4009,8 +4012,11 @@ setupHsScriptOptions
40094012
, useDistPref = builddir
40104013
, useLoggingHandle = Nothing -- this gets set later
40114014
, useWorkingDir = Just srcdir
4012-
, useExtraPathEnv = elabExeDependencyPaths elab
4013-
, useExtraEnvOverrides = dataDirsEnvironmentForPlan distdir plan
4015+
, useExtraPathEnv = elabExeDependencyPaths elab ++ elabProgramPathExtra
4016+
, -- note that the above adds the extra-prog-path directly following the elaborated
4017+
-- dep paths, so that it overrides the normal path, but _not_ the elaborated extensions
4018+
-- for build-tools-depends.
4019+
useExtraEnvOverrides = dataDirsEnvironmentForPlan distdir plan
40144020
, useWin32CleanHack = False -- TODO: [required eventually]
40154021
, forceExternalSetupMethod = isParallelBuild
40164022
, setupCacheLock = Just cacheLock

cabal-install/tests/UnitTests/Distribution/Client/ArbitraryInstances.hs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,24 @@ import Distribution.Solver.Types.PackageConstraint (PackageProperty (..))
4545

4646
import Data.Coerce (Coercible, coerce)
4747
import Network.URI (URI (..), URIAuth (..), isUnreserved)
48-
import Test.QuickCheck (Arbitrary(..), Gen, NonEmptyList(..),
49-
arbitraryBoundedEnum, choose, elements, frequency, genericShrink,
50-
liftArbitrary, listOf, oneof, resize, sized, shrinkBoundedEnum, suchThat, vectorOf)
48+
import Test.QuickCheck
49+
( Arbitrary (..)
50+
, Gen
51+
, NonEmptyList (..)
52+
, arbitraryBoundedEnum
53+
, choose
54+
, elements
55+
, frequency
56+
, genericShrink
57+
, liftArbitrary
58+
, listOf
59+
, oneof
60+
, resize
61+
, shrinkBoundedEnum
62+
, sized
63+
, suchThat
64+
, vectorOf
65+
)
5166
import Test.QuickCheck.GenericArbitrary (genericArbitrary)
5267
import Test.QuickCheck.Instances.Cabal ()
5368

0 commit comments

Comments
 (0)