Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the Cabal API with sandboxes #2112

Closed
nh2 opened this issue Sep 17, 2014 · 6 comments
Closed

Using the Cabal API with sandboxes #2112

nh2 opened this issue Sep 17, 2014 · 6 comments

Comments

@nh2
Copy link
Member

nh2 commented Sep 17, 2014

I have a question about the Cabal API and sandboxes.

When I'm using cabal configure in my project (which has a sandbox configured), everything is fine and I get no warnings.

However, if I use the Cabal API to configure the project like this: https://gist.github.com/nh2/cabe35a058f10ff5313d/8653affaf7ceb5190ce03f44333e9d45af174726 then I get:

% runhaskell cabal-packagedb-test.hs
Configuring ganeti-2.12...
Warning: This package indirectly depends on multiple versions of the same
package. This is highly likely to cause a compile failure.
package snap-server-0.9.4.5 requires mtl-2.1.3.1
package snap-core-0.9.6.3 requires mtl-2.1.3.1
package parsec-3.1.5 requires mtl-2.1.3.1
package lens-4.0.5 requires mtl-2.1.3.1
package json-0.7 requires mtl-2.1.3.1
package hslogger-1.2.4 requires mtl-2.1.3.1
package exceptions-0.6.1 requires mtl-2.1.3.1
package aeson-0.7.0.4 requires mtl-2.1.3.1
package regex-base-0.93.2 requires mtl-2.2.1
package ganeti-2.12 requires mtl-2.2.1
package zlib-enum-0.2.3.1 requires transformers-0.3.0.0
package transformers-compat-0.3.3.3 requires transformers-0.3.0.0
package transformers-base-0.4.2 requires transformers-0.3.0.0
package temporary-1.2.0.3 requires transformers-0.3.0.0
package semigroupoids-4.0.4 requires transformers-0.3.0.0
package profunctors-4.2.0.1 requires transformers-0.3.0.0
package mtl-2.1.3.1 requires transformers-0.3.0.0
package monads-tf-0.1.0.2 requires transformers-0.3.0.0
package monad-control-0.3.3.0 requires transformers-0.3.0.0
package lens-4.0.5 requires transformers-0.3.0.0
package exceptions-0.6.1 requires transformers-0.3.0.0
package enumerator-0.4.20 requires transformers-0.3.0.0
package distributive-0.4.4 requires transformers-0.3.0.0
package contravariant-0.6.1.1 requires transformers-0.3.0.0
package comonad-4.2.2 requires transformers-0.3.0.0
package blaze-builder-enumerator-0.2.0.6 requires transformers-0.3.0.0
package MonadCatchIO-transformers-0.3.1.2 requires transformers-0.3.0.0
package transformers-base-0.4.3 requires transformers-0.4.1.0
package mtl-2.2.1 requires transformers-0.4.1.0
package ganeti-2.12 requires transformers-0.4.1.0
package monad-control-0.3.3.0 requires transformers-base-0.4.2
package lifted-base-0.2.3.0 requires transformers-base-0.4.2
package ganeti-2.12 requires transformers-base-0.4.3

How does it work that cabal configure finds a way to configure the project without using multiple versions, but the Cabal API doesn't? Am I using the API correctly here?

My first guess is that somehow that I'm accidentally escaping the sandbox, because the output is talking about transformers-base-0.4.3 which I don't even have installed in my sandbox:

% cabal sandbox hc-pkg list transformers-base
/home/niklas/opt/ghc-7.8/lib/ghc-7.8.3/package.conf.d
/home/niklas/ganeti/.cabal-sandbox/x86_64-linux-ghc-7.8.3-packages.conf.d
   transformers-base-0.4.2

Same for transformers:

% cabal sandbox hc-pkg list transformers
/home/niklas/opt/ghc-7.8/lib/ghc-7.8.3/package.conf.d
   transformers-0.3.0.0
/home/niklas/ganeti/.cabal-sandbox/x86_64-linux-ghc-7.8.3-packages.conf.d

The only place from which Cabal can know about transformers-0.4.1.0 is from outside the sandbox:

% ghc-pkg list transformers
/home/niklas/opt/ghc-7.8/lib/ghc-7.8.3/package.conf.d
   transformers-0.3.0.0
/home/niklas/.ghc/x86_64-linux-7.8.3/package.conf.d
   transformers-0.4.1.0

Or is setting configPackageDBs = [Just "path/to/sandbox/packagedb"] as I do here not enough, and allows cabal to use the normal home directory package db?

@nh2
Copy link
Member Author

nh2 commented Sep 17, 2014

I just noticed that in cabal.sandbox.config, there's a user-install: False. So I commented out the configUserInstall = toFlag True I used so far, and it seems to work now.

Is this the reason? Do I have to set configUserInstall to False if I want to refer to the sandbox / does the sandbox count as a global package db? If so, could we mention that in the haddocks of configUserInstall?

@23Skidoo
Copy link
Member

Yes, we use user-install: False with sandboxes. There's a reason for this, which I don't remember off hand. This is really a hack, and we should be distinguishing between sandbox, global and user install types instead.

Second, there is currently no easily-accessible API for working with sandboxes since the sandbox-related code mostly resides inside cabal-install. So making code that uses Cabal API work with sandboxes can be a bit challenging, as you seem to have already noticed ;-)

@ezyang
Copy link
Contributor

ezyang commented Sep 19, 2014

It's also worth noting that the Cabal API has a very simple constraint solver, and is not the one used by cabal configure; that constraint solver lives in cabal-install and is not easily accessible.

@nh2
Copy link
Member Author

nh2 commented Sep 20, 2014

These are interesting points. It would be great if somebody could make a small summary of those and add them to a section in the Cabal API: "What does one have to take into account when working with sandboxes?"

@ttuegel
Copy link
Member

ttuegel commented Apr 24, 2015

Related to #1848.

@ttuegel ttuegel added this to the cabal-install-1.24 milestone Apr 24, 2015
@23Skidoo 23Skidoo modified the milestones: cabal-install 1.24, cabal-install 1.26 Feb 21, 2016
@ezyang ezyang modified the milestone: cabal-install 2.0 Sep 6, 2016
@phadej
Copy link
Collaborator

phadej commented Aug 31, 2020

sandbox functionality is removed.

@phadej phadej closed this as completed Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants