diff --git a/doctest.cabal b/doctest.cabal
--- a/doctest.cabal
+++ b/doctest.cabal
@@ -1,5 +1,5 @@
 name:             doctest
-version:          0.9.3
+version:          0.9.4
 synopsis:         Test interactive Haskell examples
 description:      The doctest program checks examples in source code comments.
                   It is modeled after doctest for Python
@@ -45,14 +45,14 @@
     , Run
     , Util
   build-depends:
-      base        >= 4.0  && < 4.7
-    , ghc         >= 6.12 && < 7.8
+      base          == 4.*
+    , ghc           >= 6.12 && < 7.8
     , syb
     , deepseq
     , directory
     , filepath
     , process
-    , ghc-paths   == 0.1.*
+    , ghc-paths     == 0.1.*
     , transformers
 
 executable doctest
@@ -63,7 +63,7 @@
   hs-source-dirs:
       driver
   build-depends:
-      base        >= 4.0  && < 4.7
+      base          == 4.*
     , doctest
 
 test-suite spec
@@ -80,20 +80,22 @@
   c-sources:
       test/integration/with-cbits/foo.c
   build-depends:
-      base        >= 4.0  && < 4.7
-    , ghc         >= 6.12 && < 7.8
+      base-compat   >= 0.2.1
+    , ghc
     , syb
     , deepseq
     , directory
+    , filepath
     , process
-    , ghc-paths   == 0.1.*
+    , ghc-paths
     , transformers
-    , HUnit       == 1.2.*
-    , hspec       >= 1.3
-    , QuickCheck  >= 2.5
-    , stringbuilder >= 0.2
-    , silently
-    , filepath
+
+    , HUnit
+    , hspec         >= 1.3
+    , QuickCheck    >= 2.5
+    , stringbuilder >= 0.4
+    , silently      >= 1.2.4
+    , setenv
 
 test-suite doctests
   main-is:
diff --git a/src/Help.hs b/src/Help.hs
--- a/src/Help.hs
+++ b/src/Help.hs
@@ -6,6 +6,7 @@
 import           Paths_doctest (version)
 import           Data.Version (showVersion)
 import           Config as GHC
+import           Interpreter (ghc)
 
 usage :: String
 usage = unlines [
@@ -23,3 +24,4 @@
 printVersion = do
   putStrLn ("doctest version " ++ showVersion version)
   putStrLn ("using version " ++ GHC.cProjectVersion ++ " of the GHC API")
+  putStrLn ("using " ++ ghc)
diff --git a/src/Interpreter.hs b/src/Interpreter.hs
--- a/src/Interpreter.hs
+++ b/src/Interpreter.hs
@@ -3,6 +3,7 @@
 , eval
 , safeEval
 , withInterpreter
+, ghc
 ) where
 
 import           System.IO
diff --git a/src/Run.hs b/src/Run.hs
--- a/src/Run.hs
+++ b/src/Run.hs
@@ -12,7 +12,9 @@
 import           Control.Monad (when)
 import           System.Exit (exitFailure)
 import           System.IO
+import           System.Environment (getEnvironment)
 
+import           Control.Applicative
 import qualified Control.Exception as E
 import           Panic
 
@@ -21,6 +23,13 @@
 import           Report
 import qualified Interpreter
 
+ghcPackageDbFlag :: String
+#if __GLASGOW_HASKELL__ >= 706
+ghcPackageDbFlag = "-package-db"
+#else
+ghcPackageDbFlag = "-package-conf"
+#endif
+
 -- | Run doctest with given list of arguments.
 --
 -- Example:
@@ -35,17 +44,26 @@
   | "--help"    `elem` args = putStr usage
   | "--version" `elem` args = printVersion
   | otherwise = do
+      -- Look up the HASKELL_PACKAGE_SANDBOX environment variable and, if
+      -- present, add it to the list of package databases GHC searches.
+      -- Intended to make testing from inside sandboxes such as cabal-dev
+      -- simpler.
+      packageConf <- lookup "HASKELL_PACKAGE_SANDBOX" <$> getEnvironment
+      let addPackageConf = case packageConf of
+            Nothing -> id
+            Just p  -> \rest -> ghcPackageDbFlag : p : rest
+
       let (f, args_) = stripOptGhc args
       when f $ do
         hPutStrLn stderr "WARNING: --optghc is deprecated, doctest now accepts arbitrary GHC options\ndirectly."
         hFlush stderr
-      r <- doctest_ args_ `E.catch` \e -> do
+      r <- doctest_ (addPackageConf args_) `E.catch` \e -> do
         case fromException e of
           Just (UsageError err) -> do
             hPutStrLn stderr ("doctest: " ++ err)
             hPutStrLn stderr "Try `doctest --help' for more information."
             exitFailure
-          _ -> E.throw e
+          _ -> E.throwIO e
       when (not $ isSuccess r) exitFailure
 
 isSuccess :: Summary -> Bool
