@@ -107,7 +107,7 @@ data SessionLoadingOptions = SessionLoadingOptions
107
107
-- or 'Nothing' to respect the cradle setting
108
108
, getCacheDirs :: String -> [String ] -> IO CacheDirs
109
109
-- | Return the GHC lib dir to use for the 'unsafeGlobalDynFlags'
110
- , getInitialGhcLibDir :: IO (Maybe LibDir )
110
+ , getInitialGhcLibDir :: FilePath -> IO (Maybe LibDir )
111
111
, fakeUid :: InstalledUnitId
112
112
-- ^ unit id used to tag the internal component built by ghcide
113
113
-- To reuse external interface files the unit ids must match,
@@ -152,26 +152,25 @@ loadWithImplicitCradle mHieYaml rootDir = do
152
152
setCurrentDirectory rootDir
153
153
loadImplicitHieCradle $ addTrailingPathSeparator rootDir
154
154
155
- getInitialGhcLibDirDefault :: IO (Maybe LibDir )
156
- getInitialGhcLibDirDefault = do
157
- dir <- IO. getCurrentDirectory
158
- hieYaml <- findCradle def dir
159
- cradle <- loadCradle def hieYaml dir
155
+ getInitialGhcLibDirDefault :: FilePath -> IO (Maybe LibDir )
156
+ getInitialGhcLibDirDefault rootDir = do
157
+ hieYaml <- findCradle def rootDir
158
+ cradle <- loadCradle def hieYaml rootDir
160
159
hPutStrLn stderr $ " setInitialDynFlags cradle: " ++ show cradle
161
160
libDirRes <- getRuntimeGhcLibDir cradle
162
161
case libDirRes of
163
162
CradleSuccess libdir -> pure $ Just $ LibDir libdir
164
163
CradleFail err -> do
165
- hPutStrLn stderr $ " Couldn't load cradle for libdir: " ++ show (err,dir ,hieYaml,cradle)
164
+ hPutStrLn stderr $ " Couldn't load cradle for libdir: " ++ show (err,rootDir ,hieYaml,cradle)
166
165
pure Nothing
167
166
CradleNone -> do
168
167
hPutStrLn stderr " Couldn't load cradle (CradleNone)"
169
168
pure Nothing
170
169
171
170
-- | Sets `unsafeGlobalDynFlags` on using the hie-bios cradle and returns the GHC libdir
172
- setInitialDynFlags :: SessionLoadingOptions -> IO (Maybe LibDir )
173
- setInitialDynFlags SessionLoadingOptions {.. } = do
174
- libdir <- getInitialGhcLibDir
171
+ setInitialDynFlags :: FilePath -> SessionLoadingOptions -> IO (Maybe LibDir )
172
+ setInitialDynFlags rootDir SessionLoadingOptions {.. } = do
173
+ libdir <- getInitialGhcLibDir rootDir
175
174
dynFlags <- mapM dynFlagsForPrinting libdir
176
175
mapM_ setUnsafeGlobalDynFlags dynFlags
177
176
pure libdir
0 commit comments