:cd now causes all modules to be unloaded.
This is the easy fix for a problem whereby changing directories will
cause GHC to try to demand-load objects from the wrong place, because
it is using relative pathnames.
It's not obvious what the "right" thing to do is if the user changes
directory with :cd and then does a :reload. Perhaps the right thing
to do is to make the search path "sticky", so that it stays relative
to the original current directory. This would probably require some
re-engineering of GHC to only use absolute paths internally.
{-# OPTIONS -#include "Linker.h" #-}
-----------------------------------------------------------------------------
{-# OPTIONS -#include "Linker.h" #-}
-----------------------------------------------------------------------------
--- $Id: InteractiveUI.hs,v 1.156 2003/07/02 19:41:43 ross Exp $
+-- $Id: InteractiveUI.hs,v 1.157 2003/07/21 14:33:19 simonmar Exp $
--
-- GHC Interactive User Interface
--
--
-- GHC Interactive User Interface
--
changeDirectory :: String -> GHCi ()
changeDirectory dir = do
changeDirectory :: String -> GHCi ()
changeDirectory dir = do
+ state <- getGHCiState
+ when (targets state /= []) $
+ io $ putStr "Warning: changing directory causes all loaded modules to be unloaded, \n\
+ \because the search path has changed.\n"
+ dflags <- io getDynFlags
+ cmstate1 <- io (cmUnload (cmstate state) dflags)
+ setGHCiState state{ cmstate = cmstate1, targets = [] }
+ setContextAfterLoad []
dir <- expandPath dir
io (setCurrentDirectory dir)
dir <- expandPath dir
io (setCurrentDirectory dir)