@@ -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,
@@ -140,31 +140,29 @@ loadWithImplicitCradle :: Maybe FilePath
140
140
-- if no 'hie.yaml' location is given.
141
141
-> IO (HieBios. Cradle Void )
142
142
loadWithImplicitCradle mHieYaml rootDir = do
143
- crdl <- case mHieYaml of
143
+ case mHieYaml of
144
144
Just yaml -> HieBios. loadCradle yaml
145
145
Nothing -> loadImplicitHieCradle $ addTrailingPathSeparator rootDir
146
- return crdl
147
146
148
- getInitialGhcLibDirDefault :: IO (Maybe LibDir )
149
- getInitialGhcLibDirDefault = do
150
- dir <- IO. getCurrentDirectory
151
- hieYaml <- findCradle def dir
152
- cradle <- loadCradle def hieYaml dir
147
+ getInitialGhcLibDirDefault :: FilePath -> IO (Maybe LibDir )
148
+ getInitialGhcLibDirDefault rootDir = do
149
+ hieYaml <- findCradle def rootDir
150
+ cradle <- loadCradle def hieYaml rootDir
153
151
hPutStrLn stderr $ " setInitialDynFlags cradle: " ++ show cradle
154
152
libDirRes <- getRuntimeGhcLibDir cradle
155
153
case libDirRes of
156
154
CradleSuccess libdir -> pure $ Just $ LibDir libdir
157
155
CradleFail err -> do
158
- hPutStrLn stderr $ " Couldn't load cradle for libdir: " ++ show (err,dir ,hieYaml,cradle)
156
+ hPutStrLn stderr $ " Couldn't load cradle for libdir: " ++ show (err,rootDir ,hieYaml,cradle)
159
157
pure Nothing
160
158
CradleNone -> do
161
159
hPutStrLn stderr " Couldn't load cradle (CradleNone)"
162
160
pure Nothing
163
161
164
162
-- | Sets `unsafeGlobalDynFlags` on using the hie-bios cradle and returns the GHC libdir
165
- setInitialDynFlags :: SessionLoadingOptions -> IO (Maybe LibDir )
166
- setInitialDynFlags SessionLoadingOptions {.. } = do
167
- libdir <- getInitialGhcLibDir
163
+ setInitialDynFlags :: FilePath -> SessionLoadingOptions -> IO (Maybe LibDir )
164
+ setInitialDynFlags rootDir SessionLoadingOptions {.. } = do
165
+ libdir <- getInitialGhcLibDir rootDir
168
166
dynFlags <- mapM dynFlagsForPrinting libdir
169
167
mapM_ setUnsafeGlobalDynFlags dynFlags
170
168
pure libdir
@@ -423,6 +421,7 @@ loadSessionWithOptions SessionLoadingOptions{..} dir = do
423
421
logWarning logger $ implicitCradleWarning lfp
424
422
425
423
cradle <- loadCradle hieYaml dir
424
+ lfp <- flip makeRelative cfp <$> getCurrentDirectory
426
425
427
426
when optTesting $ mRunLspT lspEnv $
428
427
sendNotification (SCustomMethod " ghcide/cradle/loaded" ) (toJSON cfp)
0 commit comments