How to change path of cabal config file?
Asked Answered
K

1

8

I am using HaskellPlatform-2012.4.0.0 on Win7. It's installed as portable. Paths are managed through .bat file so ghci and ghc works.
But cabal installs it self at C:\Users\name\AppData\Roaming\cabal\
To circumvent that I did:

cabal update
edit config file
delete all files except config

Changed paths:

remote-repo-cache: d:\h1\cabal\packages 
world-file: d:\h1\cabal\world
build-summary: d:\h1\cabal\logs\build.log

It works, but it's far from truly portable.

Cabal config is bigger problem. It seems that it must be left in C:\Users\name\AppData\Roaming\cabal which is not portable at all.
First run of cabal update says Config file path source is default config file.

Questions:
1. where is that default config file?
2. can remote-repo-cache, world-file and other paths be relative?
3. is there a way of setting default cabal path so it never goes to C:\Users\name\AppData\Roaming\cabal

Kowtko answered 16/1, 2013 at 21:42 Comment(4)
Looks like it can be set with the CABAL_CONFIG env variable, see: github.com/haskell/cabal/commit/…Raseda
To my surprise SET CABAL_CONFIG=%~dp0cabal\bin\config works :) It's important to say that config is file name. Paths inside config file are still wrong, but that could be fixed by implanting config file before cabal starts for the first time.Kowtko
I am not 100% sure, but it seems that paths in config need to be absolute. Relative paths create Haskell\cabal folders in current dir where you started cabal install xxx :D Absolute path \Haskell\cabal is ok for cabal update, but doesn't work for cabal install xxx Only pure absolute path D:\Haskell\cabal works. p.s. put your comment as an answer. it covers questions 1&3. So far it seems that nothing could be done about q2.Kowtko
@Nathan Howell: Anytime now would be good ;)Kowtko
C
4

Run cabal with:

cabal --config-file="path/to/config"
Corny answered 16/1, 2013 at 23:45 Comment(5)
That gives cabal: no command given (try --help) or cabal: unrecognized option '--config-file=d:\h1\cabal\bin\config'Kowtko
You cert.ainly need to provide a command :) What version of cabal-install do you have?Corny
cabal-install version 0.14.0 it can not be updated through cabal install cabal-install. what command? cabal update or cabal install with that switch says cabal: unrecognized option '--config-file=d:\cfg'Kowtko
@Kowtko I have the same version, you have to put the switch before any command. Like cabal --config-file=... install ...Corny
cabal --config-file="D:\HaskellStack\cabal\config" updateTullus

© 2022 - 2024 — McMap. All rights reserved.