Skip to content

Commit 77f87fb

Browse files
committed
loadCradle: change working dir to cradle location
1 parent 41bf8b8 commit 77f87fb

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,16 @@ loadWithImplicitCradle :: Maybe FilePath
141141
-- if no 'hie.yaml' location is given.
142142
-> IO (HieBios.Cradle Void)
143143
loadWithImplicitCradle mHieYaml rootDir = do
144-
crdl <- case mHieYaml of
145-
Just yaml -> HieBios.loadCradle yaml
146-
Nothing -> loadImplicitHieCradle $ addTrailingPathSeparator rootDir
147-
return crdl
144+
case mHieYaml of
145+
Just yaml -> do
146+
-- change the cwd to the cradle location in order to support relative
147+
-- paths in the cradle definition
148+
setCurrentDirectory (takeDirectory yaml)
149+
HieBios.loadCradle yaml
150+
Nothing -> do
151+
-- change the cwd to the workspace root for consistency with the Just case
152+
setCurrentDirectory rootDir
153+
loadImplicitHieCradle $ addTrailingPathSeparator rootDir
148154

149155
getInitialGhcLibDirDefault :: IO (Maybe LibDir)
150156
getInitialGhcLibDirDefault = do

0 commit comments

Comments
 (0)