@@ -15,6 +15,7 @@ import qualified Data.Text.IO as T
15
15
import Path ( (</>) , parent )
16
16
import Path.Extra ( toFilePathNoTrailingSep )
17
17
import RIO.Process ( HasProcessContext (.. ), exeSearchPathL )
18
+ import Stack.Config ( determineStackRootAndOwnership )
18
19
import Stack.Constants
19
20
( docDirSuffix , stackGlobalConfigOptionName
20
21
, stackRootOptionName
@@ -41,14 +42,22 @@ import Stack.Types.EnvConfig
41
42
, packageDatabaseExtra , packageDatabaseLocal
42
43
)
43
44
import Stack.Types.GHCVariant ( HasGHCVariant (.. ) )
44
- import Stack.Types.GlobalOpts ( globalOptsBuildOptsMonoidL )
45
+ import Stack.Types.GlobalOpts
46
+ ( GlobalOpts (.. ), globalOptsBuildOptsMonoidL )
45
47
import Stack.Types.Platform ( HasPlatform (.. ) )
46
48
import Stack.Types.Runner ( HasRunner (.. ), Runner , globalOptsL )
47
49
import qualified System.FilePath as FP
48
50
49
- -- | Print out useful path information in a human-readable format (and
50
- -- support others later).
51
+ -- | Print out useful path information in a human-readable format (and support
52
+ -- others later).
51
53
path :: [Text ] -> RIO Runner ()
54
+ -- Distinguish a request for only the Stack root, as such a request does not
55
+ -- require 'withDefaultEnvConfig'.
56
+ path [key] | key == stackRootOptionName' = do
57
+ clArgs <- view $ globalOptsL. to globalConfigMonoid
58
+ liftIO $ do
59
+ (_, stackRoot, _) <- determineStackRootAndOwnership clArgs
60
+ T. putStrLn $ T. pack $ toFilePathNoTrailingSep stackRoot
52
61
path keys = do
53
62
let -- filter the chosen paths in flags (keys), or show all of them if no
54
63
-- specific paths chosen.
@@ -172,7 +181,7 @@ data UseHaddocks a
172
181
paths :: [(String , Text , UseHaddocks (PathInfo -> Text ))]
173
182
paths =
174
183
[ ( " Global Stack root directory"
175
- , T. pack stackRootOptionName
184
+ , stackRootOptionName'
176
185
, WithoutHaddocks $ view (stackRootL. to toFilePathNoTrailingSep. to T. pack))
177
186
, ( " Global Stack configuration file"
178
187
, T. pack stackGlobalConfigOptionName
@@ -258,3 +267,7 @@ paths =
258
267
, " local-hpc-root"
259
268
, WithoutHaddocks $ T. pack . toFilePathNoTrailingSep . piHpcDir )
260
269
]
270
+
271
+ -- | 'Text' equivalent of 'stackRootOptionName'.
272
+ stackRootOptionName' :: Text
273
+ stackRootOptionName' = T. pack stackRootOptionName
0 commit comments