haskell / cabal

Official upstream development repository for Cabal and cabal-install

Home Page:https://haskell.org/cabal

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Offer install flag: do not download dependencies

snoyberg opened this issue · comments

There are times where we would like to prevent cabal-install from downloading dependencies, such as when bandwidth is limited or when using an external tool to download tarballs. It would be good to have a flag to the install command (strawman: --no-download) to prevent it from trying to perform downloads.

I actually implemented this some time ago because I (thought that I) needed it for sandboxes. The sandbox issue was solved in a different way, so the offline mode patch wasn't merged. Should be easy to resurrect it.

My patch is a bit simplistic, though: it works by rejecting install plans that contain non-local packages. This could be also implemented by modifying the solver to not consider such packages.

For my specific use case, failing would be acceptable, though I can certainly imagine other use cases that would have different requirements.

(And thanks for the quick reply!)

I would like this too.

Btw, I've been wanting a related feature that allows to limit the solver to only consider an explicitly specified set of additional dependencies for computing the install-plan. Right now I have to repeatedly call cabal install --dry and find out if the solver picked up any additional build-dep I didn't allow/specify, and add a respective --constraint flag, and repeat this process until a fixpoint is reached.

@hvr Could you open a separate ticket for that request? As I see it, @snoyberg's request doesn't affect the solver at all. Your request would, but the feature should be extremely easy to add, modulo bikeshedding about the name and syntax of the flag.

Ah, sorry, I've not read the discussion in detail. Ok, a solution affecting the solver for the original change has also been discussed, even though that's not how I originally understood the request. I'm open to add solver-changing flags for this (in particular as this is only about adding additional preferences, which is very easy to do), if that's what people would prefer.