Skip to content

Commit 1e25507

Browse files
committed
loadCradle: change working dir to cradle location
1 parent 0b3bb10 commit 1e25507

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
@@ -140,10 +140,16 @@ loadWithImplicitCradle :: Maybe FilePath
140140
-- if no 'hie.yaml' location is given.
141141
-> IO (HieBios.Cradle Void)
142142
loadWithImplicitCradle mHieYaml rootDir = do
143-
crdl <- case mHieYaml of
144-
Just yaml -> HieBios.loadCradle yaml
145-
Nothing -> loadImplicitHieCradle $ addTrailingPathSeparator rootDir
146-
return crdl
143+
case mHieYaml of
144+
Just yaml -> do
145+
-- change the cwd to the cradle location in order to support relative
146+
-- paths in the cradle definition
147+
setCurrentDirectory (takeDirectory yaml)
148+
HieBios.loadCradle yaml
149+
Nothing -> do
150+
-- change the cwd to the workspace root for consistency with the Just case
151+
setCurrentDirectory rootDir
152+
loadImplicitHieCradle $ addTrailingPathSeparator rootDir
147153

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

0 commit comments

Comments
 (0)