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 Sep 28, 2016
1 parent f0180d4 commit 45ba7b7
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 11 deletions.
9 changes: 9 additions & 0 deletions ChangeLog.md
Expand Up @@ -6,6 +6,15 @@ Release notes:

Major changes:

* 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:

* Switch the "Run from outside project" messages to debug-level, to
Expand Down
12 changes: 7 additions & 5 deletions doc/yaml_configuration.md
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
Expand Up @@ -228,9 +228,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
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
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
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
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
Expand Up @@ -1086,6 +1086,7 @@ data ConfigException
| BadStackRoot (Path Abs Dir)
| Won'tCreateStackRootInDirectoryOwnedByDifferentUser (Path Abs Dir) (Path Abs Dir) -- ^ @$STACK_ROOT@, parent dir
| UserDoesn'tOwnDirectory (Path Abs Dir)
| ManualGHCVariantSettingsAreIncompatibleWithSystemGHC
deriving Typeable
instance Show ConfigException where
show (ParseConfigFileException configFile exception) = concat
Expand Down Expand Up @@ -1181,6 +1182,13 @@ instance Show ConfigException where
, T.unpack configMonoidAllowDifferentUserName
, "' to disable this precaution."
]
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 45ba7b7

Please sign in to comment.