@@ -106,7 +106,7 @@ data SessionLoadingOptions = SessionLoadingOptions
106
106
-- or 'Nothing' to respect the cradle setting
107
107
, getCacheDirs :: String -> [String ] -> IO CacheDirs
108
108
-- | Return the GHC lib dir to use for the 'unsafeGlobalDynFlags'
109
- , getInitialGhcLibDir :: IO (Maybe LibDir )
109
+ , getInitialGhcLibDir :: FilePath -> IO (Maybe LibDir )
110
110
, fakeUid :: GHC. InstalledUnitId
111
111
-- ^ unit id used to tag the internal component built by ghcide
112
112
-- To reuse external interface files the unit ids must match,
@@ -151,26 +151,25 @@ loadWithImplicitCradle mHieYaml rootDir = do
151
151
setCurrentDirectory rootDir
152
152
loadImplicitHieCradle $ addTrailingPathSeparator rootDir
153
153
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
159
158
hPutStrLn stderr $ " setInitialDynFlags cradle: " ++ show cradle
160
159
libDirRes <- getRuntimeGhcLibDir cradle
161
160
case libDirRes of
162
161
CradleSuccess libdir -> pure $ Just $ LibDir libdir
163
162
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)
165
164
pure Nothing
166
165
CradleNone -> do
167
166
hPutStrLn stderr " Couldn't load cradle (CradleNone)"
168
167
pure Nothing
169
168
170
169
-- | 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
174
173
dynFlags <- mapM dynFlagsForPrinting libdir
175
174
mapM_ setUnsafeGlobalDynFlags dynFlags
176
175
pure libdir
0 commit comments