Skip to content

Commit

Permalink
Default to using a stack-installed, isolated GHC #2221
Browse files Browse the repository at this point in the history
Address option compatibility issues around the new default setting:

* Add notes to ghc-variant and setup --reinstall help texts
* Add a check to catch uses of ghc-variant in combination with
  no-system-ghc
  • Loading branch information
sjakobi committed Oct 13, 2016
1 parent a7209c9 commit 39a13ee
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 11 deletions.
8 changes: 8 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ Major changes:
autogen files and run preprocessors. The `--no-build` flag is now deprecated
because it should no longer be necessary. See
[#1364](https://github.com/commercialhaskell/stack/issues/1364)
* Stack will now always use its own GHC installation, even when a suitable GHC
installation is available on the PATH. To get the old behaviour, use
the `--system-ghc` flag or set `system-ghc: true` in your ~/.stack/config.yaml.

NB: Scripts that previously used stack in combination with a system GHC
installation should now include a `stack setup` line or use the `--install-ghc`
flag.
[#2221](https://github.com/commercialhaskell/stack/issues/2221)

Behavior changes:

Expand Down
12 changes: 7 additions & 5 deletions doc/yaml_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,13 @@ other projects by installing into your shared snapshot database.

### system-ghc

Enables or disables using the GHC available on the PATH. Useful to disable if
you want to force stack to use its own installed GHC (via `stack setup`), in
cases where your system GHC my be incomplete for some reason. Default is `true`.
Enables or disables using the GHC available on the PATH.
Useful to disable if you want to save the time, bandwidth or storage space needed to setup an isolated GHC.
Default is `false`.

```yaml
# Turn off system GHC
system-ghc: false
# Turn on system GHC
system-ghc: true
```

### install-ghc
Expand Down Expand Up @@ -452,6 +452,8 @@ Specify a variant binary distribution of GHC to use. Known values:
[setup-info](#setup-info) so `stack setup` knows where to download it, or
pass the `stack setup --ghc-bindist` argument on the command-line

This option is incompatible with `system-ghc: true`.

### ghc-build

(Since 1.2.1)
Expand Down
7 changes: 5 additions & 2 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,12 @@ configFromConfigMonoid configStackRoot configUserConfigPath mresolver mproject C

configGHCVariant0 = getFirst configMonoidGHCVariant
configGHCBuild = getFirst configMonoidGHCBuild
configSystemGHC = fromFirst False configMonoidSystemGHC

configSystemGHC = fromFirst (isNothing configGHCVariant0) configMonoidSystemGHC
configInstallGHC = fromFirst False configMonoidInstallGHC
when (isJust configGHCVariant0 && configSystemGHC) $
throwM ManualGHCVariantSettingsAreIncompatibleWithSystemGHC

let configInstallGHC = fromFirst False configMonoidInstallGHC
configSkipGHCCheck = fromFirst False configMonoidSkipGHCCheck
configSkipMsys = fromFirst False configMonoidSkipMsys

Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Options/ConfigParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ configOptsParser hide0 =
<*> nixOptsParser True
<*> firstBoolFlags
"system-ghc"
"using the system installed GHC (on the PATH) if available and a matching version"
"using the system installed GHC (on the PATH) if available and a matching version. Disabled by default."
hide
<*> firstBoolFlags
"install-ghc"
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Options/GhcVariantParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ghcVariantParser hide =
readGHCVariant
(long "ghc-variant" <> metavar "VARIANT" <>
help
"Specialized GHC variant, e.g. integersimple (implies --no-system-ghc)" <>
"Specialized GHC variant, e.g. integersimple (incompatible with --system-ghc)" <>
hideMods hide
)
where
Expand Down
3 changes: 2 additions & 1 deletion src/Stack/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,8 @@ ensureCompiler sopts = do
(soptsStackYaml sopts)
(fromMaybe
("Try running \"stack setup\" to install the correct GHC into "
<> T.pack (toFilePath (configLocalPrograms config)))
<> T.pack (toFilePath (configLocalPrograms config))
<> " or use \"--system-ghc\" to use a suitable compiler available on your PATH.")
$ soptsResolveMissingGHC sopts)

-- Install msys2 on windows, if necessary
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/SetupCmd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ setupParser = SetupCmdOpts
"The default is to install the version implied by the resolver.")))
<*> OA.boolFlags False
"reinstall"
"reinstalling GHC, even if available (implies no-system-ghc)"
"reinstalling GHC, even if available (incompatible with --system-ghc)"
OA.idm
<*> OA.boolFlags False
"upgrade-cabal"
Expand Down
8 changes: 8 additions & 0 deletions src/Stack/Types/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,7 @@ data ConfigException
| Won'tCreateStackRootInDirectoryOwnedByDifferentUser (Path Abs Dir) (Path Abs Dir) -- ^ @$STACK_ROOT@, parent dir
| UserDoesn'tOwnDirectory (Path Abs Dir)
| FailedToCloneRepo String
| ManualGHCVariantSettingsAreIncompatibleWithSystemGHC
deriving Typeable
instance Show ConfigException where
show (ParseConfigFileException configFile exception) = concat
Expand Down Expand Up @@ -1213,6 +1214,13 @@ instance Show ConfigException where
, commandName
, " is installed and available to stack on your PATH environment variable."
]
show ManualGHCVariantSettingsAreIncompatibleWithSystemGHC = T.unpack $ T.concat
[ "stack can only control the "
, configMonoidGHCVariantName
, " of its own GHC installations. Please use '--no-"
, configMonoidSystemGHCName
, "'."
]
instance Exception ConfigException

showOptions :: WhichSolverCmd -> String
Expand Down

0 comments on commit 39a13ee

Please sign in to comment.