Skip to content

Commit

Permalink
Merge pull request #6350 from commercialhaskell/fix6340
Browse files Browse the repository at this point in the history
Fix #6340 `stack path --stack-root` does not need environment
  • Loading branch information
mpilgrem authored Nov 30, 2023
2 parents 3d0a483 + 23b9aa1 commit b270c00
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Behavior changes:
manager is available. In YAML configuration files, the `notify-if-nix-on-path`
key is introduced, to allow the notification to be muted if unwanted.
* Drop support for Intero (end of life in November 2019).
* `stack path --stack-root` no longer sets up Stack's environment and does not
load Stack's configuration.

Other enhancements:

Expand Down
1 change: 1 addition & 0 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module Stack.Config
, getProjectConfig
, withBuildConfig
, withNewLogFunc
, determineStackRootAndOwnership
) where

import Control.Monad.Extra ( firstJustM )
Expand Down
21 changes: 17 additions & 4 deletions src/Stack/Path.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import qualified Data.Text.IO as T
import Path ( (</>), parent )
import Path.Extra ( toFilePathNoTrailingSep )
import RIO.Process ( HasProcessContext (..), exeSearchPathL )
import Stack.Config ( determineStackRootAndOwnership )
import Stack.Constants
( docDirSuffix, stackGlobalConfigOptionName
, stackRootOptionName
Expand All @@ -41,14 +42,22 @@ import Stack.Types.EnvConfig
, packageDatabaseExtra, packageDatabaseLocal
)
import Stack.Types.GHCVariant ( HasGHCVariant (..) )
import Stack.Types.GlobalOpts ( globalOptsBuildOptsMonoidL )
import Stack.Types.GlobalOpts
( GlobalOpts (..), globalOptsBuildOptsMonoidL )
import Stack.Types.Platform ( HasPlatform (..) )
import Stack.Types.Runner ( HasRunner (..), Runner, globalOptsL )
import qualified System.FilePath as FP

-- | Print out useful path information in a human-readable format (and
-- support others later).
-- | Print out useful path information in a human-readable format (and support
-- others later).
path :: [Text] -> RIO Runner ()
-- Distinguish a request for only the Stack root, as such a request does not
-- require 'withDefaultEnvConfig'.
path [key] | key == stackRootOptionName' = do
clArgs <- view $ globalOptsL.to globalConfigMonoid
liftIO $ do
(_, stackRoot, _) <- determineStackRootAndOwnership clArgs
T.putStrLn $ T.pack $ toFilePathNoTrailingSep stackRoot
path keys = do
let -- filter the chosen paths in flags (keys), or show all of them if no
-- specific paths chosen.
Expand Down Expand Up @@ -172,7 +181,7 @@ data UseHaddocks a
paths :: [(String, Text, UseHaddocks (PathInfo -> Text))]
paths =
[ ( "Global Stack root directory"
, T.pack stackRootOptionName
, stackRootOptionName'
, WithoutHaddocks $ view (stackRootL.to toFilePathNoTrailingSep.to T.pack))
, ( "Global Stack configuration file"
, T.pack stackGlobalConfigOptionName
Expand Down Expand Up @@ -258,3 +267,7 @@ paths =
, "local-hpc-root"
, WithoutHaddocks $ T.pack . toFilePathNoTrailingSep . piHpcDir )
]

-- | 'Text' equivalent of 'stackRootOptionName'.
stackRootOptionName' :: Text
stackRootOptionName' = T.pack stackRootOptionName

0 comments on commit b270c00

Please sign in to comment.