commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.95k stars 842 forks source link

Stack does not distinguish global and project-level configuration files in certain error messages #6606

Closed mpilgrem closed 2 weeks ago

mpilgrem commented 3 weeks ago

Motivation: #6602

Illustrated by (but not limited to) the error generated by Haskell script file:

{- stack script
   --snapshot nightly-2024-06-07
   --package dhall
-}

main = pure ()

Currently, the stackYaml field of a value of type BuildConfig can refer to either a global or a project-level configuration file, in part because of Stack.Config.withBuildConfig (extract):

 (project', stackYaml) <- case config.project of
    ...
    PCNoProject extraDeps -> do
      p <- ...
      pure (p, config.userConfigPath) -- <<<< refering to the global configuration file!

It seems to me that types could be used to distinguish values that represent the location of global configuration files from those that represent the location of any project-level configuration file. Also, the field is a potential misnomer, as stackYaml could be understood to refer to stack.yaml, the default name of a project-level configuration file.