Cabal: Suggestion: CABAL_HOME or similar

Created on 30 Jan 2020  路  9Comments  路  Source: haskell/cabal

I am working on switching Homebrew packages from using v1-build to v2-build. As part of this, I am also trying to simplify the setup. Homebrew builds packages using the ordinary user. This may not be technically ideal, but it's not feasible to change (at least not for me). As a result, package build scripts need to be carefully written not to touch anything outside of the temporary directory in which they run - in particular, they should not write or read anything from $HOME. By default, cabal does touch things in $HOME/.cabal (maybe somewhere else too?). It would be nice if there was a CABAL_HOME environment variable, or similar, that can be used to guarantee that all such operations will be done relative to some directory. I see #6516 mentions an undocumented CABAL_DIR variable. Is that essentially it?

All 9 comments

Unfortunately no, I'll try to resolve #6516 properly, by writing a section in documentation, so I don't need to repeat myself.

I see #6516 mentions an undocumented CABAL_DIR variable. Is that essentially it?

Unfortunately no

@phadej maybe i am misunderstanding you but i just tested changing CABAL_DIR and it seems it does somewhat i expected (maybe not the expected by @athas?): it does not touch %APPDATA\cabal, at least with cabal v2-updateand cabal v2-build

D:\ws\haskell\haskell-ide-engine>set CABAL_DIR=D:\cabal

D:\ws\haskell\haskell-ide-engine>dir D:\cabal /B
No se encuentra el archivo

D:\ws\haskell\haskell-ide-engine>dir %APPDATA%\cabal
No se encuentra el archivo

D:\ws\haskell\haskell-ide-engine>cabal update
Config file path source is default config file.
Config file D:\cabal\config not found.
Writing default configuration to D:\cabal\config
Downloading the latest package list from hackage.haskell.org

D:\ws\haskell\haskell-ide-engine>type D:\cabal\config | grep "D:\\cabal"
remote-repo-cache: D:\cabal\packages
-- logs-dir: D:\cabal\logs
world-file: D:\cabal\world
extra-prog-path: D:\cabal\bin
build-summary: D:\cabal\logs\build.log
installdir: D:\cabal\bin
  -- prefix: D:\cabal

D:\ws\haskell\haskell-ide-engine>dir D:\cabal /B
config
packages

D:\ws\haskell\haskell-ide-engine>dir %APPDATA%\cabal /B
No se encuentra el archivo

D:\ws\haskell\haskell-ide-engine>cabal build
.....
D:\ws\haskell\haskell-ide-engine>dir D:\cabal /B
config
packages
store

D:\ws\haskell\haskell-ide-engine>dir %APPDATA%\cabal /B
No se encuentra el archivo

ok, maybe you was meaning that CABAL_DIR works that way but it is not documented?

@jneira as I said, it doesn't completely. And I'd rather not repeat myself.

Dont want to bother anymore, only mention that it works well enough for me cause i wanted to free space in the default C: drive in the azure ci windows image (so i dont care if cabal touches C: while it does not take much space)

@jneira ?

Sorry, my phone come alive in my pants pocket

So CABAL_DIR is what I need here, isn't it? (At least until the glorious XDG future.)

@athas i think it worths trying it in local (removing ~\.cabal, setting the variable to other location and doing a update + full build to test if something is created inside ~\.cabal)

Was this page helpful?
0 / 5 - 0 ratings