diff --git a/ghcide/session-loader/Development/IDE/Session.hs b/ghcide/session-loader/Development/IDE/Session.hs index f8492464aa..8d6a6f6309 100644 --- a/ghcide/session-loader/Development/IDE/Session.hs +++ b/ghcide/session-loader/Development/IDE/Session.hs @@ -770,8 +770,17 @@ newComponentCache -> IO ( [TargetDetails], (IdeResult HscEnvEq, DependencyInfo)) newComponentCache recorder exts cradlePath cfp hsc_env uids ci = do let df = componentDynFlags ci - let hscEnv' = hscSetFlags df hsc_env - { hsc_IC = (hsc_IC hsc_env) { ic_dflags = df } } + hscEnv' <- + -- Add the options for the current component to the HscEnv + -- We want to call `setSessionDynFlags` instead of `hscSetFlags` + -- because `setSessionDynFlags` also initializes the package database, + -- which we need for any changes to the package flags in the dynflags + -- to be visible. + -- See #2693 + evalGhcEnv hsc_env $ do + _ <- setSessionDynFlags $ df + getSession + let newFunc = maybe newHscEnvEqPreserveImportPaths newHscEnvEq cradlePath henv <- newFunc hscEnv' uids diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index 73de4078df..e7b8ab335c 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -5583,8 +5583,7 @@ simpleSubDirectoryTest = expectNoMoreDiagnostics 0.5 simpleMultiTest :: TestTree -simpleMultiTest = knownBrokenForGhcVersions [GHC92] "#2693" $ - testCase "simple-multi-test" $ withLongTimeout $ runWithExtraFiles "multi" $ \dir -> do +simpleMultiTest = testCase "simple-multi-test" $ withLongTimeout $ runWithExtraFiles "multi" $ \dir -> do let aPath = dir "a/A.hs" bPath = dir "b/B.hs" adoc <- openDoc aPath "haskell" @@ -5614,7 +5613,7 @@ simpleMultiTest2 = testCase "simple-multi-test2" $ runWithExtraFiles "multi" $ \ -- Now with 3 components simpleMultiTest3 :: TestTree -simpleMultiTest3 = knownBrokenForGhcVersions [GHC92] "#2693" $ +simpleMultiTest3 = testCase "simple-multi-test3" $ runWithExtraFiles "multi" $ \dir -> do let aPath = dir "a/A.hs" bPath = dir "b/B.hs"