stack on windows : need a way to configure ghc-paths

Created on 16 Sep 2015  路  11Comments  路  Source: commercialhaskell/stack

Hello.

(I have a low disk space at my local C-drive at windows)

Are there any way to configure ghc-paths at windows to non-default (LOCALAPPDATA-based) location?

I've just looked through the source code (src/Stack/Config.hs), but found no way to do that (except the way to unset "LOCALAPPDATA" env var at getWindowsProgsDir function).

awaiting pull request help wanted newcomer friendly

All 11 comments

This would be a great improvement, and should be an easy thing to modify in the codebase. PR certainly welcome.

PR (if you mean a pull-request) would be really good, but I'd like to start from the understanding the exact place we need to introduce such configuration.
Is it need to be a global stack.yml and/or command-line param?
(I spent so little time looking at the stack sources, so any hints about current stack configuration approach/architecture/design are welcome).

I'd say supporting either or both of those is fine. You're looking at modifying configLocalPrograms, defined in Stack.Types.Config.

I went over the code of paths today, so I might as well do this.
Passing it as a parameter to stack would be tedious,
And putting it in stack.yaml seems inappropriate, as it's supposed to be project-centric, and not dependant on the environemnt it's set up in.
So it probably needs to go in a global config, such as the global stack.yaml, but then we have differences between the global and local stack.yaml

Putting it in the user/global config.yaml (formerly ~/.stack/stack.yaml or /etc/stack/config, but now renamed) seems fine. The project stack.yaml is already different.

Maybe it would be good to start using some new whatever_config.yaml for such cases?

I'm currently facing the same concern, I'd like to be able to customize the install path for compiler. Ideally I'd like to edit config.yaml to define this path.

It seems to be currently hardcoded in https://github.com/commercialhaskell/stack/blob/0985d769b3786ff496733459e79b43d699f37cef/src/Stack/Config.hs#L242 with no way to override.

I'd prefer configuration by envvar.

diff --git a/src/Stack/Config.hs b/src/Stack/Config.hs
index d3a5781..79508c2 100644
--- a/src/Stack/Config.hs
+++ b/src/Stack/Config.hs
@@ -259,14 +259,7 @@ configFromConfigMonoid configStackRoot configUserConfigPath mresolver mproject c
      let configEnvOverride _ = return origEnv

      platformOnlyDir <- runReaderT platformOnlyRelDir (configPlatform,configPlatformVariant)
-     configLocalProgramsBase <-
-         case configPlatform of
-             Platform _ Windows -> do
-                 progsDir <- getWindowsProgsDir configStackRoot origEnv
-                 return $ progsDir </> $(mkRelDir stackProgName)
-             _ ->
-                 return $
-                 configStackRoot </> $(mkRelDir "programs")
+     configLocalProgramsBase <- getConfigLocalProgramsBase configStackRoot configPlatform origEnv
      let configLocalPrograms = configLocalProgramsBase </> platformOnlyDir

      configLocalBin <-
@@ -356,6 +349,21 @@ getWindowsProgsDir stackRoot m =
             return $ lad </> $(mkRelDir "Programs")
         Nothing -> return $ stackRoot </> $(mkRelDir "Programs")

+-- | Get directory to local programs base
+getConfigLocalProgramsBase :: MonadThrow m
+                           => Path Abs Dir
+                           -> Platform
+                           -> EnvOverride
+                           -> m (Path Abs Dir)
+getConfigLocalProgramsBase stackRoot platform m =
+    case Map.lookup "STACK_PROGSBASE" $ unEnvOverride m of
+        Just t -> parseAbsDir $ T.unpack t
+        Nothing -> case platform of
+            Platform _ Windows -> do
+                progsDir <- getWindowsProgsDir stackRoot m
+                return $ progsDir </> $(mkRelDir stackProgName)
+            _ -> return $ stackRoot </> $(mkRelDir "programs")
+
 -- | An environment with a subset of BuildConfig used for setup.
 data MiniConfig = MiniConfig Manager GHCVariant Config
 instance HasConfig MiniConfig where

I'm Haskell noob, but that's the single parameter for which I search solution since few hours. But now I see that its better to work around. Maybe just mklink the folder e.g.:
mklink /D x86_64-windows C:\Users\USER\AppData\Local\Programs\stack\x86_64-windows

You can set local-programs-path parameter in config.yaml file #2766
This issue may be closed

Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sjakobi picture sjakobi  路  4Comments

symbiont-joseph-kachmar picture symbiont-joseph-kachmar  路  3Comments

sjakobi picture sjakobi  路  3Comments

fizruk picture fizruk  路  3Comments

igrep picture igrep  路  3Comments