Skip to content

Commit bda47a4

Browse files
committed
Improve error message for invalid --work-dir #2954
1 parent 529730d commit bda47a4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Stack/Options/ConfigParser.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
module Stack.Options.ConfigParser where
22

33
import Data.Char
4+
import Data.Either.Combinators
45
import Data.Monoid.Extra
56
import qualified Data.Set as Set
67
import Options.Applicative
78
import Options.Applicative.Builder.Extra
9+
import Path
810
import Stack.Constants
911
import Stack.Options.BuildMonoidParser
1012
import Stack.Options.DockerParser
@@ -46,7 +48,7 @@ configOptsParser hide0 =
4648
"(Overrides any STACK_ROOT environment variable)")
4749
<> hide
4850
))
49-
<*> optionalFirst (relDirOption
51+
<*> optionalFirst (option (eitherReader (mapLeft showWorkDirError . parseRelDir))
5052
( long "work-dir"
5153
<> metavar "WORK-DIR"
5254
<> help "Override work directory (default: .stack-work)"
@@ -129,3 +131,6 @@ configOptsParser hide0 =
129131
toDumpLogs (First (Just True)) = First (Just DumpAllLogs)
130132
toDumpLogs (First (Just False)) = First (Just DumpNoLogs)
131133
toDumpLogs (First Nothing) = First Nothing
134+
showWorkDirError err = show err ++
135+
"\nNote that --work-dir must be a relative child directory, because work-dirs outside of the package are not supported by Cabal." ++
136+
"\nSee https://github.com/commercialhaskell/stack/issues/2954"

0 commit comments

Comments
 (0)