@@ -106,7 +106,7 @@ data SessionLoadingOptions = SessionLoadingOptions
106106 -- or 'Nothing' to respect the cradle setting
107107 , getCacheDirs :: String -> [String ] -> IO CacheDirs
108108 -- | Return the GHC lib dir to use for the 'unsafeGlobalDynFlags'
109- , getInitialGhcLibDir :: IO (Maybe LibDir )
109+ , getInitialGhcLibDir :: FilePath -> IO (Maybe LibDir )
110110 , fakeUid :: GHC. InstalledUnitId
111111 -- ^ unit id used to tag the internal component built by ghcide
112112 -- To reuse external interface files the unit ids must match,
@@ -151,26 +151,25 @@ loadWithImplicitCradle mHieYaml rootDir = do
151151 setCurrentDirectory rootDir
152152 loadImplicitHieCradle $ addTrailingPathSeparator rootDir
153153
154- getInitialGhcLibDirDefault :: IO (Maybe LibDir )
155- getInitialGhcLibDirDefault = do
156- dir <- IO. getCurrentDirectory
157- hieYaml <- findCradle def dir
158- cradle <- loadCradle def hieYaml dir
154+ getInitialGhcLibDirDefault :: FilePath -> IO (Maybe LibDir )
155+ getInitialGhcLibDirDefault rootDir = do
156+ hieYaml <- findCradle def rootDir
157+ cradle <- loadCradle def hieYaml rootDir
159158 hPutStrLn stderr $ " setInitialDynFlags cradle: " ++ show cradle
160159 libDirRes <- getRuntimeGhcLibDir cradle
161160 case libDirRes of
162161 CradleSuccess libdir -> pure $ Just $ LibDir libdir
163162 CradleFail err -> do
164- hPutStrLn stderr $ " Couldn't load cradle for libdir: " ++ show (err,dir ,hieYaml,cradle)
163+ hPutStrLn stderr $ " Couldn't load cradle for libdir: " ++ show (err,rootDir ,hieYaml,cradle)
165164 pure Nothing
166165 CradleNone -> do
167166 hPutStrLn stderr " Couldn't load cradle (CradleNone)"
168167 pure Nothing
169168
170169-- | Sets `unsafeGlobalDynFlags` on using the hie-bios cradle and returns the GHC libdir
171- setInitialDynFlags :: SessionLoadingOptions -> IO (Maybe LibDir )
172- setInitialDynFlags SessionLoadingOptions {.. } = do
173- libdir <- getInitialGhcLibDir
170+ setInitialDynFlags :: FilePath -> SessionLoadingOptions -> IO (Maybe LibDir )
171+ setInitialDynFlags rootDir SessionLoadingOptions {.. } = do
172+ libdir <- getInitialGhcLibDir rootDir
174173 dynFlags <- mapM dynFlagsForPrinting libdir
175174 mapM_ setUnsafeGlobalDynFlags dynFlags
176175 pure libdir
0 commit comments