Skip to content

Loading…

how to have cabal user packages not land in ~/.cabal/ #27031

Closed
cartazio opened this Issue · 14 comments

3 participants

@cartazio

paging @mikemcquaid, i found out the (in restrospect obvious) way to do this! (i'm terribly sorry i wasn't properly aware of this before)

if you run cabal help, you'll notice

» cabal help
This program is the command line interface to the Haskell Cabal infrastructure.
See http://www.haskell.org/cabal/ for more information.

Usage: cabal COMMAND [FLAGS]
   or: cabal [GLOBAL FLAGS]

Global flags:
 -h --help                     Show this help text
 -V --version                  Print version information
    --numeric-version          Print just the version number
    --config-file=FILE         Set an alternate location for the config file
    --sandbox-config-file=FILE Set an alternate location for the sandbox config

now, the actual way to read that should be


or:
cabal [GLOBAL FLAGS] Command [Flags]

basically you could totally have every invocation of cabal install foo
be cabal --config-file=/usr/local/Celler/ghc-7.8.1rc2/dotcabal/config foo
and you'll get the install behavior you want

@mikemcquaid
Homebrew member

Ok, great. Does this help us with e.g. pandoc? I'm not quite sure I understand the invocation; where does that config file come from? Remind me what should be in it?

@cartazio

a) it should, but 2) yes, theres the cabal config file to be sorted out. I'm happy to make sure some core haskell person who's on a mac will help you work this out. I'm starting this ticket now because this gives the skeleton for the right approach

please regard all of this as rough starter notes, i just wanted to make sure i started documenting / sharing this before i got side tracked. Theres definitely some finer details that i'm likely wrong about.

the first time you invoke cabal, if it doesn't see a config file at the target path it'll create one. I'm going to paste the default cabal 1.18 one (), and then paste ""heres the lines to edit". Notice that most of it is prefixed by -- which is commenting that line out to be the defautl value

@cartazio
-- This is the configuration file for the 'cabal' command line tool.

-- The available configuration options are listed below.
-- Some of them have default values listed.

-- Lines (like this one) beginning with '--' are comments.
-- Be careful with spaces and indentation because they are
-- used to indicate layout for nested sections.


remote-repo: hackage.haskell.org:http://hackage.haskell.org/packages/archive
remote-repo-cache: /Users/carter/.cabal/packages
-- local-repo:
-- logs-dir:
world-file: /Users/carter/.cabal/world
-- verbose: 1
-- compiler: ghc
-- with-compiler:
-- with-hc-pkg:
-- scratchdir:
-- program-prefix: 
-- program-suffix: 
-- library-vanilla: True
-- library-profiling: False
-- shared:
-- executable-dynamic: False
-- executable-profiling: False
-- optimization: True
-- library-for-ghci: False
-- split-objs: False
-- executable-stripping: True
-- user-install: True
-- package-db:
-- flags:
-- extra-include-dirs:
-- extra-lib-dirs:
extra-prog-path: /Users/carter/.cabal/bin
-- tests: False
-- library-coverage: False
-- benchmarks: False
-- cabal-lib-version:
-- constraint:
-- preference:
-- solver: choose
-- documentation: False
-- doc-index-file: $datadir/doc/index.html
-- max-backjumps: 200
-- reorder-goals: False
-- shadow-installed-packages:
-- reinstall: False
-- avoid-reinstalls: False
-- force-reinstalls: False
-- upgrade-dependencies: False
-- root-cmd:
-- symlink-bindir:
build-summary: /Users/carter/.cabal/logs/build.log
-- build-log:
remote-build-reporting: anonymous
-- one-shot: False
jobs: $ncpus
-- username:
-- password:

install-dirs user
  -- prefix: /Users/carter/.cabal
  -- bindir: $prefix/bin
  -- libdir: $prefix/lib
  -- libsubdir: $arch-$os-$compiler/$pkgid
  -- libexecdir: $prefix/libexec
  -- datadir: $prefix/share
  -- datasubdir: $arch-$os-$compiler/$pkgid
  -- docdir: $datadir/doc/$arch-$os-$compiler/$pkgid
  -- htmldir: $docdir/html
  -- haddockdir: $htmldir
  -- sysconfdir: $prefix/etc

install-dirs global
  -- prefix: /usr/local
  -- bindir: $prefix/bin
  -- libdir: $prefix/lib
  -- libsubdir: $arch-$os-$compiler/$pkgid
  -- libexecdir: $prefix/libexec
  -- datadir: $prefix/share
  -- datasubdir: $arch-$os-$compiler/$pkgid
  -- docdir: $datadir/doc/$arch-$os-$compiler/$pkgid
  -- htmldir: $docdir/html
  -- haddockdir: $htmldir
  -- sysconfdir: $prefix/etc

program-locations 
  -- alex-location:
  -- ar-location:
  -- c2hs-location:
  -- cpphs-location:
  -- ffihugs-location:
  -- gcc-location:
  -- ghc-location:
  -- ghc-pkg-location:
  -- greencard-location:
  -- haddock-location:
  -- happy-location:
  -- hmake-location:
  -- hpc-location:
  -- hsc2hs-location:
  -- hscolour-location:
  -- hugs-location:
  -- jhc-location:
  -- ld-location:
  -- lhc-location:
  -- lhc-pkg-location:
  -- nhc98-location:
  -- pkg-config-location:
  -- ranlib-location:
  -- strip-location:
  -- tar-location:
  -- uhc-location:

program-default-options 
  -- alex-options:
  -- ar-options:
  -- c2hs-options:
  -- cpphs-options:
  -- ffihugs-options:
  -- gcc-options:
  -- ghc-options:
  -- ghc-pkg-options:
  -- greencard-options:
  -- haddock-options:
  -- happy-options:
  -- hmake-options:
  -- hpc-options:
  -- hsc2hs-options:
  -- hscolour-options:
  -- hugs-options:
  -- jhc-options:
  -- ld-options:
  -- lhc-options:
  -- lhc-pkg-options:
  -- nhc98-options:
  -- pkg-config-options:
  -- ranlib-options:
  -- strip-options:
  -- tar-options:
  -- uhc-options:
@cartazio

some of these fields likely reflect the defaults / nature of the install on my system. I'll do some experimentation to sort out a suitable "template" config makes sense for brew (or if it even needs one!).

but the key (nice thing) is that this with some work should allow the "isolated builds" sandboxing to work out nicely..... I'll need to double check but i'm pretty opitimistic

@cartazio

normally the config file is the one at ~/.cabal/config

@cartazio

but you certainly have a point that the current sandbox tooling doesn't quite give nice tooling for "isolated builds, public installs" out of the box. I'm more than happy to help you figure that out.

@mikemcquaid
Homebrew member

Yeh. I ideally want to be able to build e.g. pandoc in such a way I don't need to have cabal or even ghc installed afterwards.

@cartazio

so maybe for each binary, it gets its own sandbox.

as far as I recall, your issue was you were trying to do a sandboxed bootstrap of alex and happy, right? Which actually isn't needed because GHC ALWAYS comes with happy and alex. Always. Its baked into the ghc build system. (though i should double check)

@mikemcquaid
Homebrew member

The issue was that pandoc was trying to build them and failing.

@cartazio

huh,
i'll have time next week to try to reproduce that next week.

How did you not have alex + happy installed on your system and on path though?

@mikemcquaid
Homebrew member

Don't know. I'll see if I can dig up the formula again.

@jacknagel

@mikemcquaid is this stale or still actionable?

@cartazio

i'm happy to help advise on the "play nice with haskell side" or "why isn't X working" side, dont' have the bandwidth to hep concretely though

@mikemcquaid
Homebrew member

This is done now given the new e.g. pandoc formulae.

@mikemcquaid mikemcquaid closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.