@@ -35,11 +35,12 @@ import qualified RIO.Text as T
35
35
scriptCmd :: ScriptOpts -> GlobalOpts -> IO ()
36
36
scriptCmd opts go' = do
37
37
file <- resolveFile' $ soFile opts
38
- let go = go'
38
+ let scriptDir = parent file
39
+ go = go'
39
40
{ globalConfigMonoid = (globalConfigMonoid go')
40
41
{ configMonoidInstallGHC = First $ Just True
41
42
}
42
- , globalStackYaml = SYLNoConfig $ parent file
43
+ , globalStackYaml = SYLNoConfig scriptDir
43
44
}
44
45
withDefaultBuildConfigAndLock go $ \ lk -> do
45
46
-- Some warnings in case the user somehow tries to set a
@@ -92,7 +93,8 @@ scriptCmd opts go' = do
92
93
withNewLocalBuildTargets targets $ Stack.Build. build Nothing lk
93
94
94
95
let ghcArgs = concat
95
- [ [" -hide-all-packages" ]
96
+ [ [" -i" , " -i" ++ toFilePath scriptDir]
97
+ , [" -hide-all-packages" ]
96
98
, maybeToList colorFlag
97
99
, map (\ x -> " -package" ++ x)
98
100
$ Set. toList
@@ -109,13 +111,12 @@ scriptCmd opts go' = do
109
111
SEInterpret -> exec (" run" ++ compilerExeName wc)
110
112
(ghcArgs ++ toFilePath file : soArgs opts)
111
113
_ -> do
112
- let dir = parent file
113
114
-- Use readProcessStdout_ so that (1) if GHC does send any output
114
115
-- to stdout, we capture it and stop it from being sent to our
115
116
-- stdout, which could break scripts, and (2) if there's an
116
117
-- exception, the standard output we did capture will be reported
117
118
-- to the user.
118
- withWorkingDir (toFilePath dir ) $ proc
119
+ withWorkingDir (toFilePath scriptDir ) $ proc
119
120
(compilerExeName wc)
120
121
(ghcArgs ++ [toFilePath file])
121
122
(void . readProcessStdout_)
0 commit comments