cabal sandbox support #191

Open
luite opened this Issue Jun 25, 2014 · 5 comments

Projects

None yet

4 participants

@luite
Member
luite commented Jun 25, 2014

cabal sandboxes seem to be mostly working now, but there are some issues. To start:

cabal sandbox init
echo "compiler: ghcjs" >> cabal.config
cabal install -v

installs the package with ghcjs in the sandbox, uses the correct package db to register everything. but if you then run:

cabal sandbox hc-pkg list

cabal passes the wrong package db location. it's fixable by editing the location in cabal.sandbox.config, but it seems that shouldn't be necessary, since cabal install could find it by itself

also we should try to get cabal issue 1884 fixed, since that would be very handy when we start distributing updated packages through http://hackage.ghcjs.org/

@luite luite added the bug label Jun 25, 2014
@luite
Member
luite commented Jul 29, 2014

initialize a sandbox now with cabal sandbox init ghcjs to get a ghcjs package database even if your default compiler is ghc. I've updated the readme with up to date instructions.

I'm leaving this open since this adds some command line option and might change

@geraldus

Cool! Great stuff!

@crodjer
crodjer commented Sep 5, 2014

Not sure if this is the most relevant thread for this comment.

I tried to setup ghcjs under a cabal sandbox of its own. I avoid installing global (system or user) haskell packages because it very easily has caused conflicts for me in the past. This is the directory structure:

ghcjs/
      cabal/
      ghcjs-prim/
      ghcjs/
      .cabal-sandbox
      .cabal-sandbox/bin/
      cabal.sandbox.config

where cabal, ghcjs-prim and ghcjs are the respective ghcjs git repositories. The installs worked fine (with a minor issue with automatic HTTP-4000.2.18 install), in that I have the executables: cabal, ghcjs* and the like available under the sandbox and added to path. Here are the install logs if required: http://lpaste.net/7384673344613777408. But with this setup, when I try to run ghcjs-boot, things fail. The command seems to run under the (user) global packages instead of the sandbox's. Is there a way that I can run it under the sandbox?
Here are the boot logs:

ghcjs-boot logs

program ghcjs found at /home/rohan/workspace/src/ghcjs/.cabal-sandbox/bin/ghcjs
program ghcjs-pkg found at /home/rohan/workspace/src/ghcjs/.cabal-sandbox/bin/ghcjs-pkg
program ghcjs-run found at /home/rohan/workspace/src/ghcjs/.cabal-sandbox/bin/ghcjs-run
program ghc found at /usr/bin/ghc
program ghc-pkg found at /usr/bin/ghc-pkg
program cabal found at /home/rohan/workspace/src/ghcjs/.cabal-sandbox/bin/cabal
program node found at /usr/bin/node
program haddock-ghcjs found at /home/rohan/workspace/src/ghcjs/.cabal-sandbox/bin/haddock-ghcjs
program git found at /usr/bin/git
program alex found at /usr/bin/alex
program happy found at /usr/bin/happy
program patch found at /usr/bin/patch
program tar found at /usr/bin/tar
program cpp found at /usr/bin/cpp
program bash found at /usr/bin/bash
program autoreconf found at /usr/bin/autoreconf
program make found at /usr/bin/make
/home/rohan/workspace/src/ghcjs$ [node]: /usr/bin/node "--version"
/home/rohan/workspace/src/ghcjs$ [cabal]: /home/rohan/workspace/src/ghcjs/.cabal-sandbox/bin/cabal "--numeric-version"
/home/rohan/workspace/src/ghcjs$ [ghcjs-pkg]: /home/rohan/workspace/src/ghcjs/.cabal-sandbox/bin/ghcjs-pkg "--numeric-ghc-version"
/home/rohan/workspace/src/ghcjs$ [ghcjs-pkg]: /home/rohan/workspace/src/ghcjs/.cabal-sandbox/bin/ghcjs-pkg "--numeric-ghcjs-version"
/home/rohan/workspace/src/ghcjs$ [ghc]: /usr/bin/ghc "--numeric-version"
/home/rohan/workspace/src/ghcjs$ [ghcjs]: /home/rohan/workspace/src/ghcjs/.cabal-sandbox/bin/ghcjs "--numeric-ghc-version"
/home/rohan/workspace/src/ghcjs$ [ghcjs]: /home/rohan/workspace/src/ghcjs/.cabal-sandbox/bin/ghcjs "--numeric-version"
/home/rohan/workspace/src/ghcjs$ [ghcjs]: /home/rohan/workspace/src/ghcjs/.cabal-sandbox/bin/ghcjs "--ghcjs-booting-print" "--print-rts-profiled"
/home/rohan/workspace/src/ghcjs$ [cabal]: /home/rohan/workspace/src/ghcjs/.cabal-sandbox/bin/cabal "install" "--help"
/home/rohan/workspace/src/ghcjs$ [ghc]: /usr/bin/ghc "-e" "either error id (Text.Read.readEither \"GHCJS\" :: Either String Distribution.Simple.CompilerFlavor)"
fatal: program /usr/bin/ghc returned a nonzero exit code
fatal: GHC program /usr/bin/ghc does not have a Cabal library that supports GHCJS
(note that the Cabal library is not the same as the cabal-install program, you need a compatible version for both)
@tonyday567

I had the same issue as crodjer.
I guess ghc must reference the global Cabal library (locatable by ghc-pkg list) directly. I couldn't find any way to confirm this, or any configuration method to change it.
So I bit the global bullet and did (from the ghfjs directory as per crodjer's structure):

cabal --no-require-sandbox install --global ./cabal/Cabal
cabal --no-require-sandbox install --global ./cabal/cabal-install

I got the same error for ghcjs-boot --dev after just the Cabal install.
After the global cabal-install install ghcjs-boot --dev succeeded (yay!).

In summary, you can't yet quite get a completely sandboxed build of ghcjs.

@luite
Member
luite commented Nov 23, 2014

ghcjs-boot requires a Cabal library that supports the GHCJS compiler flavor to be available in ghc's package db, since ghcjs calls ghc for building Setup.hs scripts for packages until ghcjs has its own Cabal library (stage0, stage1a, stage1b).

Since ghcjs calls ghc from outside the sandbox, the required Cabal library is not visible there. A better method would be to have ghcjs-boot prepare a sandbox for GHC first, with just the Cabal library it needs to build the Setup.hs scripts

I'm going to make this change and a few other improvements to the installation procedure soon. The ghcjs-prim dependency for ghcjs will be dropped too starting with GHC 7.10. It was only used to get consistent Template Haskell serialization, but some TH updates have made it easier to serialize (although binary is still an undesirable dependency for template-haskell, so we couldn't actually add Binary instances to the package yet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment