Skip to content
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

cli defaults override new-build cabal.project settings #4737

Open
hvr opened this issue Sep 2, 2017 · 6 comments
Open

cli defaults override new-build cabal.project settings #4737

hvr opened this issue Sep 2, 2017 · 6 comments

Comments

@hvr
Copy link
Member

hvr commented Sep 2, 2017

It appears the fix in #4657 wasn't enough.

I was looking into why setting

allow-boot-library-installs: True

in a cabal.project file would have no effect, and it turns out it's because in rebuildProjectConfig the cli-flags have highest priority, due to

    return (projectConfig <> cliConfig, localPackages)

however, in #4657 we deliberately injected applyDefaults so the cliConfig constructed via

    cliConfig = commandLineFlagsToProjectConfig
                  globalFlags configFlags configExFlags
                  installFlags haddockFlags

already has those defaults.

And here's a dumped version of what cliConfig looks like for a simple invocation of cabal new-build w/o any CLI arguments:

ProjectConfig{projectPackages = [], projectPackagesOptional = [],
              projectPackagesRepo = [], projectPackagesNamed = [],
              projectConfigBuildOnly =
                ProjectConfigBuildOnly{projectConfigVerbosity = NoFlag,
                                       projectConfigDryRun = Flag False, projectConfigOnlyDeps = Flag False,
                                       projectConfigSummaryFile = [], projectConfigLogFile = NoFlag,
                                       projectConfigBuildReports = Flag NoReports,
                                       projectConfigReportPlanningFailure = Flag False,
                                       projectConfigSymlinkBinDir = NoFlag, projectConfigOneShot = Flag False,
                                       projectConfigNumJobs = NoFlag, projectConfigKeepGoing = Flag False,
                                       projectConfigOfflineMode = Flag False, projectConfigKeepTempFiles = Flag False,
                                       projectConfigHttpTransport = NoFlag, projectConfigIgnoreExpiry = NoFlag,
                                       projectConfigCacheDir = NoFlag, projectConfigLogsDir = NoFlag,
                                       projectConfigStoreDir = NoFlag},
              projectConfigShared =
                ProjectConfigShared{projectConfigDistDir = NoFlag,
                                    projectConfigConfigFile = NoFlag, projectConfigProjectFile = NoFlag,
                                    projectConfigHcFlavor = NoFlag, projectConfigHcPath = NoFlag,
                                    projectConfigHcPkg = NoFlag,
                                    projectConfigHaddockIndex = Flag "$datadir/doc/$arch-$os-$compiler/index.html",
                                    projectConfigRemoteRepos = [], projectConfigLocalRepos = [],
                                    projectConfigIndexState = NoFlag, projectConfigConstraints = [],
                                    projectConfigPreferences = [], projectConfigCabalVersion = NoFlag,
                                    projectConfigSolver = Flag AlwaysModular, projectConfigAllowOlder = Nothing,
                                    projectConfigAllowNewer = Nothing, projectConfigMaxBackjumps = Flag 2000,
                                    projectConfigReorderGoals = Flag (ReorderGoals False),
                                    projectConfigCountConflicts = Flag (CountConflicts True),
                                    projectConfigStrongFlags = Flag (StrongFlags False),
                                    projectConfigAllowBootLibInstalls = Flag (AllowBootLibInstalls False),
                                    projectConfigPerComponent = Flag True,
                                    projectConfigIndependentGoals = Flag (IndependentGoals False)},
              projectConfigProvenance = fromList [],
              projectConfigLocalPackages =
                PackageConfig{packageConfigProgramPaths = MapLast{getMapLast = fromList []},
                              packageConfigProgramArgs = MapMappend{getMapMappend = fromList []},
                              packageConfigProgramPathExtra = [], packageConfigFlagAssignment = [],
                              packageConfigVanillaLib = NoFlag, packageConfigSharedLib = NoFlag,
                              packageConfigStaticLib = NoFlag, packageConfigDynExe = NoFlag,
                              packageConfigProf = NoFlag, packageConfigProfLib = NoFlag,
                              packageConfigProfExe = NoFlag, packageConfigProfDetail = NoFlag,
                              packageConfigProfLibDetail = NoFlag, packageConfigConfigureArgs = [],
                              packageConfigOptimization = NoFlag, packageConfigProgPrefix = NoFlag,
                              packageConfigProgSuffix = NoFlag, packageConfigExtraLibDirs = [],
                              packageConfigExtraFrameworkDirs = [], packageConfigExtraIncludeDirs = [],
                              packageConfigGHCiLib = NoFlag, packageConfigSplitObjs = NoFlag,
                              packageConfigStripExes = NoFlag, packageConfigStripLibs = NoFlag,
                              packageConfigTests = NoFlag, packageConfigBenchmarks = NoFlag,
                              packageConfigCoverage = NoFlag, packageConfigRelocatable = NoFlag,
                              packageConfigDebugInfo = NoFlag, packageConfigRunTests = NoFlag,
                              packageConfigDocumentation = Flag False,
                              packageConfigHaddockHoogle = Flag False, packageConfigHaddockHtml = Flag False,
                              packageConfigHaddockHtmlLocation = NoFlag,
                              packageConfigHaddockForeignLibs = Flag False,
                              packageConfigHaddockExecutables = Flag False,
                              packageConfigHaddockTestSuites = Flag False,
                              packageConfigHaddockBenchmarks = Flag False,
                              packageConfigHaddockInternal = Flag False, packageConfigHaddockCss = NoFlag,
                              packageConfigHaddockHscolour = Flag False,
                              packageConfigHaddockHscolourCss = NoFlag, packageConfigHaddockContents = NoFlag,
                              packageConfigHaddockForHackage = NoFlag},
              projectConfigSpecificPackage = MapMappend{getMapMappend = fromList []}}

As can be seen, all flags which have a definitive Flag ... constructor will effectively override cabal.project settings, and specifically

projectConfigAllowBootLibInstalls = Flag (AllowBootLibInstalls False),

was the setting I was looking for...

and it appears to me, that the default injection should instead happen in rebuildProjectConfig (which is called by establishProjectBaseContext)

/cc @alexbiehl @23Skidoo

@hvr hvr added the type: bug label Sep 2, 2017
@hvr
Copy link
Member Author

hvr commented Sep 2, 2017

After some more investigation, I think that defaults are supposed to be applied in

resolveSolverSettings :: ProjectConfig -> SolverSettings

resolveBuildTimeSettings :: Verbosity -> CabalDirLayout -> ProjectConfig -> BuildTimeSettings

PS: I'm currently testing applyFlagDefaults = id locally to see how bad this currently is.

@leftaroundabout
Copy link

Is this by any chance related to the issue I'm having here (with Cabal c480f69):

$ cabal install distributive-0.5.3 --flags="semigroups tagged"
Resolving dependencies...
Configuring distributive-0.5.3...
Failed to install distributive-0.5.3
Build log ( /home/sagemuej/.cabal/logs/ghc-7.10.2/distributive-0.5.3-1mEGskitVaeLQN6CJ7QtG8.log ):
cabal: Entering directory '/tmp/cabal-tmp-31691/distributive-0.5.3'
[1 of 1] Compiling Main             ( /tmp/cabal-tmp-31691/distributive-0.5.3/dist/setup/setup.hs, /tmp/cabal-tmp-31691/distributive-0.5.3/dist/setup/Main.o )
Linking /tmp/cabal-tmp-31691/distributive-0.5.3/dist/setup/setup ...
Configuring distributive-0.5.3...
setup: '--exact-configuration' was given, but the following flags were not
specified: FlagName "semigroups", FlagName "tagged"
cabal: Leaving directory '/tmp/cabal-tmp-31691/distributive-0.5.3'
cabal: Error: some packages failed to install:
distributive-0.5.3-1mEGskitVaeLQN6CJ7QtG8 failed during the configure step.
The exception was:
ExitFailure 1

(I really don't see why I should need to define those flags at all, as they're enabled by default. I don't recall ever needing to specify flags in old builds. But now the “flags were not
specified” error happens regardless of what --flags="..." I give cabal-install.)

@hvr
Copy link
Member Author

hvr commented Sep 16, 2017

@leftaroundabout what you're experience appears to be a totally different issue, which looks serious enough to deserve its own issue being filed...

@leftaroundabout
Copy link

Thanks, I did that.

@hvr
Copy link
Member Author

hvr commented Sep 18, 2017

@dcoutts confirmed that I'm on the right track regarding #4737 (comment)

...so we need to basically revert 1e90ae4 (#4422) & #4657 and instead start fixing/finishing the resolve* functions to kill any left-over partiality.

See also comments at

-- Resolving configuration to settings
--
-- | Resolved configuration for the solver. The idea is that this is easier to
-- use than the raw configuration because in the raw configuration everything
-- is optional (monoidial). In the 'BuildTimeSettings' every field is filled
-- in, if only with the defaults.
--
-- Use 'resolveSolverSettings' to make one from the project config (by
-- applying defaults etc).
--

hvr added a commit to hvr/cabal that referenced this issue Nov 12, 2017
hvr added a commit to hvr/cabal that referenced this issue Nov 12, 2017
hvr added a commit to hvr/cabal that referenced this issue Nov 12, 2017
hvr added a commit to hvr/cabal that referenced this issue Jan 7, 2018
hvr added a commit to hvr/cabal that referenced this issue Jan 7, 2018
hvr added a commit to hvr/cabal that referenced this issue Jan 7, 2018
hvr added a commit to hvr/cabal that referenced this issue Feb 8, 2018
hvr added a commit to hvr/cabal that referenced this issue Feb 8, 2018
hvr added a commit to hvr/cabal that referenced this issue Feb 8, 2018
hvr added a commit that referenced this issue Feb 12, 2018
Replace flag-defaulting hack by proper solution

Addresses  #4737 and  fixes #5139
@andreabedini
Copy link
Collaborator

I haven't checked the code but from comments above it looks like this was fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants