Skip to content

Commit

Permalink
Ignore Globally Installed Packages When Loading GHCI
Browse files Browse the repository at this point in the history
  • Loading branch information
s0kil committed Jan 15, 2021
1 parent 2daec0c commit 61590df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions exe/IHP/IDE/DevServer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ main = do

-- Print IHP Version when in debug mode
when isDebugMode (putStrLn ("IHP Version: " <> Version.ihpVersion))

let ?context = Context { actionVar, portConfig, appStateRef, isDebugMode }

threadId <- myThreadId
Expand Down Expand Up @@ -67,7 +67,7 @@ handleAction state@(AppState { statusServerState = StatusServerNotStarted }) (Up
handleAction state@(AppState { statusServerState = StatusServerStarted { } }) (UpdateStatusServerState StatusServerNotStarted) = pure state { statusServerState = StatusServerNotStarted }
handleAction state@(AppState { statusServerState = StatusServerPaused { } }) (UpdateStatusServerState statusServerState) = pure state { statusServerState = StatusServerNotStarted }
handleAction state@(AppState { liveReloadNotificationServerState = LiveReloadNotificationServerNotStarted }) (UpdateLiveReloadNotificationServerState liveReloadNotificationServerState) = pure state { liveReloadNotificationServerState }
handleAction state@(AppState { liveReloadNotificationServerState = LiveReloadNotificationServerStarted {} }) (UpdateLiveReloadNotificationServerState liveReloadNotificationServerState) =
handleAction state@(AppState { liveReloadNotificationServerState = LiveReloadNotificationServerStarted {} }) (UpdateLiveReloadNotificationServerState liveReloadNotificationServerState) =
case liveReloadNotificationServerState of
LiveReloadNotificationServerNotStarted -> pure state { liveReloadNotificationServerState }
otherwise -> error "Cannot start live reload notification server twice"
Expand All @@ -86,7 +86,7 @@ handleAction state@(AppState { appGHCIState, statusServerState, postgresState })
let statusServerState' = case statusServerState of
StatusServerStarted { .. } -> StatusServerPaused { .. }
_ -> statusServerState

pure state { appGHCIState = appGHCIState', statusServerState = statusServerState' }
RunningAppGHCI { } -> pure state -- Do nothing as app is already in running state
AppGHCINotStarted -> error "Unreachable AppGHCINotStarted"
Expand All @@ -107,7 +107,7 @@ handleAction state@(AppState { appGHCIState, statusServerState, postgresState, l
AppGHCIModulesLoaded { .. } -> AppGHCIModulesLoaded { .. }
RunningAppGHCI { .. } -> AppGHCIModulesLoaded { .. }
AppGHCINotStarted {} -> error "Modules cannot be loaded when ghci not in started state"

notifyHaskellChange liveReloadNotificationServerState

pure state { statusServerState = statusServerState', appGHCIState = newAppGHCIState }
Expand All @@ -118,7 +118,7 @@ handleAction state@(AppState { statusServerState, appGHCIState, liveReloadNotifi
AppGHCIModulesLoaded { .. } -> pure state { appGHCIState = RunningAppGHCI { .. } }
RunningAppGHCI { } -> pure state
otherwise -> pure state

handleAction state@(AppState { liveReloadNotificationServerState }) AssetChanged = do
notifyAssetChange liveReloadNotificationServerState
pure state
Expand All @@ -133,7 +133,7 @@ handleAction state@(AppState { liveReloadNotificationServerState, appGHCIState,

clearStatusServer statusServerState

let appGHCIState' =
let appGHCIState' =
case appGHCIState of
AppGHCILoading { .. } -> AppGHCILoading { .. }
AppGHCIModulesLoaded { .. } -> AppGHCILoading { .. }
Expand Down Expand Up @@ -218,6 +218,7 @@ startGHCI = do
, "-fomit-interface-pragmas"
, "-j"
, "-O0"
, "-package-env -" -- Do not load `~/.ghc/arch-os-version/environments/name file`, global packages interfere with our packages
, "-ignore-dot-ghci" -- Ignore the global ~/.ghc/ghci.conf That file sometimes causes trouble (specifically `:set +c +s`)
, "-ghci-script", ".ghci" -- Because the previous line ignored default ghci config file locations, we have to manual load our .ghci
, "+RTS", "-A512m", "-n4m", "-H512m", "-G3", "-qg", "-N"
Expand All @@ -244,7 +245,7 @@ startAppGHCI = do

libDirectory <- LibDir.findLibDirectory

let loadAppCommands =
let loadAppCommands =
[ ":script " <> cs libDirectory <> "/applicationGhciConfig"
, ":set prompt \"\"" -- Disable the prompt as this caused output such as '[38;5;208mIHP>[m Ser[v3e8r; 5s;t2a0r8tmedI' instead of 'Server started'
, "import qualified ClassyPrelude"
Expand Down
3 changes: 2 additions & 1 deletion lib/IHP/Makefile.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Use bash as we sometimes use bash specific syntax, like pipefail below
#SHELL=/bin/bash
#.SHELLFLAGS := -eu -o pipefail -c
#.SHELLFLAGS := -eu -o pipefail -c
.ONESHELL:

MAKEFLAGS += --warn-undefined-variables
Expand Down Expand Up @@ -62,6 +62,7 @@ GHC_RTS_FLAGS := -A256m -n2m -N
GHC_OPTIONS=-threaded -i. -ibuild -iConfig -iIHP
GHC_OPTIONS+= ${GHC_EXTENSIONS}
GHC_OPTIONS+= -j2
GHC_OPTIONS+= -package-env - # https://github.com/digitallyinduced/ihp/issues/130

ifneq ($(GHC_RTS_FLAGS),)
GHC_OPTIONS+= +RTS ${GHC_RTS_FLAGS} --RTS
Expand Down

0 comments on commit 61590df

Please sign in to comment.