Parallel cabal install --reinstall seems to ignore dependency order #1174

Closed
nh2 opened this Issue Jan 11, 2013 · 9 comments

4 participants

@nh2

I have jobs: 4 enabled in my cabal config to get parallel installs
with cabal-install >= 1.16.

When I do cabal install --reinstall --force-reinstalls world to
reinstall all packages (e.g. to enable profiling or shared), it fails
after some point, complaining that the required dependency package is
not compiled with the needed flag (for profiling / -dyn).

It looks like for reinstalls, parallel cabal-install (sometimes?) simply ignores the
necessary order.

(I'm using 1.16.0.2.)

My discussion with dcoutts on #haskell:

dcoutts: the algorithm is to not start an install job until all the dependent jobs are done
dcoutts: if you can reproduce and report it, that'd be appreciated
nh2: maybe it is tricked out by the fact that the libs are already there, but we need to reinstall them to get things like profiling/-dyn?
nh2: (I also just posted it on haskell-cafe)
dcoutts: the parallel install algorithm doesn't care about the fact that they're reinstalls
nh2: so do you mean it will just treat them as installed already?
dcoutts: no, it makes a plan for what to install and then it does it, according to the plan. It doesn't look at what's already installed, it blindly follows the plan (a dep graph, in dep order)
nh2: weird. I will try to make a minimal fresh cabal for which a world reinstall like this breaks.
dcoutts: if you only look at the install plan, you (or rather the code that executes it) can't actually tell if it's a reinstall or not
nh2: can I print the reinstall plan?
dcoutts: yes, that's what --dry-run shows you (or rather it shows just the bits of the plan that involve installing, not the bits of the plan that describe existing installed deps)
dcoutts: well, it shows the flattened plan. The real install plan is a dep graph.

@23Skidoo
Haskell member

I will try to make a minimal fresh cabal for which a world reinstall like this breaks.

That'd be appreciated.

@feuerbach

It also happenned to me a couple of times: I'd launch a parallel build, it'd fail in the middle (I don't remember what the error message was...), then I restart it without -j and it succeeds.

@23Skidoo
Haskell member

It'd be great if someone could come up with a reproducible test case. So far it sounds like some dependencies are missing from the install plan.

@nh2
nh2 commented Feb 6, 2013

OK, try this.

I installed a fairly small amount of packages (I installed them into a hsenv, but that doesn't matter) and now my configuration looks like this:

 % ghc-pkg list 
/home/niklas/haskell-7.6/.hsenv/ghc_pkg_db
/home/niklas/haskell-7.6/.hsenv/ghc/lib/ghc-7.6.2/package.conf.d
   Cabal-1.16.0
   Cabal-1.16.0.3
   HTTP-4000.2.7
   array-0.4.0.1
   attoparsec-0.10.4.0
   base-4.6.0.1
   bin-package-db-0.0.0.0
   binary-0.5.1.1
   blaze-builder-0.3.1.0
   bytestring-0.10.0.2
   containers-0.5.0.0
   deepseq-1.3.0.1
   directory-1.2.0.1
   filepath-1.3.0.1
   ghc-7.6.2
   ghc-prim-0.3.0.0
   hashable-1.2.0.5
   haskell2010-1.1.1.0
   haskell98-2.0.0.2
   hoopl-3.9.0.0
   hpc-0.6.0.0
   integer-gmp-0.5.0.0
   msgpack-0.7.2.5
   mtl-2.1.2
   network-2.4.1.0
   old-locale-1.0.0.5
   old-time-1.1.0.1
   parsec-3.1.3
   pretty-1.1.1.0
   primitive-0.5.0.1
   process-1.1.0.2
   random-1.0.1.1
   rts-1.0
   template-haskell-2.8.0.0
   text-0.11.2.3
   time-1.4.0.1
   transformers-0.3.0.0
   unix-2.6.0.1
   unordered-containers-0.2.3.0
   vector-0.10.0.1
   zlib-0.5.4.0

Now I set flags that need full recompilation in my cabal config:

library-profiling: True
shared: True
documentation: True
jobs: 4

and try to reinstall the world:

 % cabal install --reinstall world
Resolving dependencies...
In order, the following will be installed:
Cabal-1.16.0.3 (reinstall)
cabal-install-1.16.0.2 -bytestring-in-base (new package)
msgpack-0.7.2.5 (reinstall)
Warning: Note that reinstalls are always dangerous. Continuing anyway...
Configuring msgpack-0.7.2.5...
Configuring Cabal-1.16.0.3...
Building msgpack-0.7.2.5...
Failed to install msgpack-0.7.2.5
Last 10 lines of the build log (
/home/niklas/haskell-7.6/.hsenv/cabal/logs/msgpack-0.7.2.5.log ):
[3 of 7] Compiling Data.MessagePack.Pack ( Data/MessagePack/Pack.hs,
dist/build/Data/MessagePack/Pack.o )
[4 of 7] Compiling Data.MessagePack.Unpack ( Data/MessagePack/Unpack.hs,
dist/build/Data/MessagePack/Unpack.o )
[5 of 7] Compiling Data.MessagePack.Object ( Data/MessagePack/Object.hs,
dist/build/Data/MessagePack/Object.o )
[6 of 7] Compiling Data.MessagePack.Derive ( Data/MessagePack/Derive.hs,
dist/build/Data/MessagePack/Derive.o )
[7 of 7] Compiling Data.MessagePack ( Data/MessagePack.hs,
dist/build/Data/MessagePack.o )
Data/MessagePack/Pack.hs:36:18:
Could not find module `Data.Vector'
Perhaps you haven't installed the profiling libraries for package
`vector-0.10.0.1'?
Use -v to see a list of the files searched for.

It tries to install msgpack, but it fails because there are no profilin libraries for vector installed. Why does it not try to install them in multi-jobs mode?

@nh2
nh2 commented Feb 6, 2013

Here is the the same cabal install with -v:

 % cabal install -v --reinstall world
Reading available packages...
Choosing modular solver.
Resolving dependencies...
In order, the following will be installed:
Cabal-1.16.0.3 (reinstall)
cabal-install-1.16.0.2 -bytestring-in-base (new package)
msgpack-0.7.2.5 (reinstall)
Warning: Note that reinstalls are always dangerous. Continuing anyway...
Ready to install Cabal-1.16.0.3
Extracting
/home/niklas/.cabal/packages/hackage.haskell.org/Cabal/1.16.0.3/Cabal-1.16.0.3.tar.gz
Ready to install msgpack-0.7.2.5
to /tmp/Cabal-1.16.0.3-24155...
Waiting for install task to finish...
Extracting
/home/niklas/.cabal/packages/hackage.haskell.org/msgpack/0.7.2.5/msgpack-0.7.2.5.tar.gz
to /tmp/msgpack-0.7.2.5-24155...
Updating Cabal.cabal with the latest revision from the index.
Updating msgpack.cabal with the latest revision from the index.
Configuring Cabal-1.16.0.3...
Configuring msgpack-0.7.2.5...
creating /tmp/Cabal-1.16.0.3-24155/Cabal-1.16.0.3/dist/setup
creating /tmp/msgpack-0.7.2.5-24155/msgpack-0.7.2.5/dist/setup
creating /tmp/Cabal-1.16.0.3-24155/Cabal-1.16.0.3/dist
creating /tmp/msgpack-0.7.2.5-24155/msgpack-0.7.2.5/dist
creating /tmp/Cabal-1.16.0.3-24155/Cabal-1.16.0.3/dist/setup
creating /tmp/msgpack-0.7.2.5-24155/msgpack-0.7.2.5/dist/setup
/home/niklas/haskell-7.6/.hsenv/bin/ghc --make /tmp/Cabal-1.16.0.3-24155/Cabal-1.16.0.3/Setup.hs -o /tmp/Cabal-1.16.0.3-24155/Cabal-1.16.0.3/dist/setup/setup -odir /tmp/Cabal-1.16.0.3-24155/Cabal-1.16.0.3/dist/setup -hidir /tmp/Cabal-1.16.0.3-24155/Cabal-1.16.0.3/dist/setup -i -i/tmp/Cabal-1.16.0.3-24155/Cabal-1.16.0.3 -package-db /home/niklas/haskell-7.6/.hsenv/ghc_pkg_db -package-db /home/niklas/haskell-7.6/.hsenv/ghc_pkg_db -package-db /home/niklas/haskell-7.6/.hsenv/ghc/lib/ghc-7.6.2/package.conf.d
/home/niklas/.cabal/setup-exe-cache/setup-Cabal-1.16.0.3-ghc-7.6.2 configure
--verbose=2 --builddir=dist --ghc
--prefix=/home/niklas/haskell-7.6/.hsenv/cabal --enable-library-profiling
--enable-shared --user --package-db=/home/niklas/haskell-7.6/.hsenv/ghc_pkg_db
--package-db=/home/niklas/haskell-7.6/.hsenv/ghc_pkg_db
--package-db=/home/niklas/haskell-7.6/.hsenv/ghc/lib/ghc-7.6.2/package.conf.d
--constraint=vector ==0.10.0.1 --constraint=unordered-containers ==0.2.3.0
--constraint=text ==0.11.2.3 --constraint=template-haskell ==2.8.0.0
--constraint=mtl ==2.1.2 --constraint=hashable ==1.2.0.5 --constraint=ghc-prim
==0.3.0.0 --constraint=deepseq ==1.3.0.1 --constraint=containers ==0.5.0.0
--constraint=bytestring ==0.10.0.2 --constraint=blaze-builder ==0.3.1.0
--constraint=base ==4.6.0.1 --constraint=attoparsec ==0.10.4.0 --disable-tests
--disable-benchmarks
Redirecting build log to {handle:
/home/niklas/haskell-7.6/.hsenv/cabal/logs/msgpack-0.7.2.5.log}
Building msgpack-0.7.2.5...
creating /tmp/msgpack-0.7.2.5-24155/msgpack-0.7.2.5/dist/setup
/home/niklas/.cabal/setup-exe-cache/setup-Cabal-1.16.0.3-ghc-7.6.2 build
--verbose=2 --builddir=dist
Redirecting build log to {handle:
/home/niklas/haskell-7.6/.hsenv/cabal/logs/msgpack-0.7.2.5.log}
Failed to install msgpack-0.7.2.5
Last 10 lines of the build log (
/home/niklas/haskell-7.6/.hsenv/cabal/logs/msgpack-0.7.2.5.log ):
[4 of 7] Compiling Data.MessagePack.Unpack ( Data/MessagePack/Unpack.hs,
dist/build/Data/MessagePack/Unpack.o )
[5 of 7] Compiling Data.MessagePack.Object ( Data/MessagePack/Object.hs,
dist/build/Data/MessagePack/Object.o )
[6 of 7] Compiling Data.MessagePack.Derive ( Data/MessagePack/Derive.hs,
dist/build/Data/MessagePack/Derive.o )
[7 of 7] Compiling Data.MessagePack ( Data/MessagePack.hs,
dist/build/Data/MessagePack.o )
/home/niklas/haskell-7.6/.hsenv/bin/ghc --make -fbuilding-cabal-package -O
-prof -osuf p_o -hisuf p_hi -odir dist/build -hidir dist/build -stubdir
dist/build -i -idist/build -i. -idist/build/autogen -Idist/build/autogen
-Idist/build -optP-include -optPdist/build/autogen/cabal_macros.h
-package-name msgpack-0.7.2.5 -hide-all-packages -package-db
/home/niklas/haskell-7.6/.hsenv/ghc_pkg_db -package-db
/home/niklas/haskell-7.6/.hsenv/ghc_pkg_db -package-db
/home/niklas/haskell-7.6/.hsenv/ghc/lib/ghc-7.6.2/package.conf.d -package-db
dist/package.conf.inplace -package-id
attoparsec-0.10.4.0-a639f3d4205e2e6fa4778e930de0245a -package-id
base-4.6.0.1-e2868b9e4921883d688a915f0b1f3318 -package-id
blaze-builder-0.3.1.0-0afff63e220d7a9dad534a4555b4fabe -package-id
bytestring-0.10.0.2-3da4d1e402df368f2f8867ddd94de40b -package-id
containers-0.5.0.0-83506a9a856380c403b10c2964560773 -package-id
deepseq-1.3.0.1-5a51be95ce07ca5b213668b9e29a22f9 -package-id
ghc-prim-0.3.0.0-bd1d393903577692a5ef2aa7027b71f6 -package-id
hashable-1.2.0.5-6369bb0e7f86eaf80fdec96a830fe508 -package-id
mtl-2.1.2-36ff22533b21e2182d8d4647bfd2b3e7 -package-id
template-haskell-2.8.0.0-62aae5a9f1ef08ce562ad0b0e7b33600 -package-id
text-0.11.2.3-86f28037e2ba94b49dc102a8935fdf0c -package-id
unordered-containers-0.2.3.0-0db94ebdfc82b1993d9eadf5c6ef46f5 -package-id
vector-0.10.0.1-8747b1a3f3ca714799e5f3c0917b09c7 -XHaskell98 Data.MessagePack
Data.MessagePack.Assoc Data.MessagePack.Pack Data.MessagePack.Unpack
Data.MessagePack.Object Data.MessagePack.Derive Data.MessagePack.Internal.Utf8
-Wall
Data/MessagePack/Pack.hs:36:18:
Could not find module `Data.Vector'
Perhaps you haven't installed the profiling libraries for package
`vector-0.10.0.1'?
Use -v to see a list of the files searched for.
Waiting for install task to finish...

However, we already get this problem with multi-jobs mode disabled:

% cabal install --reinstall msgpack
Resolving dependencies...
In order, the following will be installed:
msgpack-0.7.2.5 (reinstall)
Warning: Note that reinstalls are always dangerous. Continuing anyway...
Configuring msgpack-0.7.2.5...
Building msgpack-0.7.2.5...
Preprocessing library msgpack-0.7.2.5...
[1 of 7] Compiling Data.MessagePack.Internal.Utf8 ( Data/MessagePack/Internal/Utf8.hs, dist/build/Data/MessagePack/Internal/Utf8.o )
[2 of 7] Compiling Data.MessagePack.Assoc ( Data/MessagePack/Assoc.hs, dist/build/Data/MessagePack/Assoc.o )
[3 of 7] Compiling Data.MessagePack.Pack ( Data/MessagePack/Pack.hs, dist/build/Data/MessagePack/Pack.o )
[4 of 7] Compiling Data.MessagePack.Unpack ( Data/MessagePack/Unpack.hs, dist/build/Data/MessagePack/Unpack.o )
[5 of 7] Compiling Data.MessagePack.Object ( Data/MessagePack/Object.hs, dist/build/Data/MessagePack/Object.o )
[6 of 7] Compiling Data.MessagePack.Derive ( Data/MessagePack/Derive.hs, dist/build/Data/MessagePack/Derive.o )
[7 of 7] Compiling Data.MessagePack ( Data/MessagePack.hs, dist/build/Data/MessagePack.o )

Data/MessagePack/Pack.hs:36:18:
    Could not find module `Data.Vector'
    Perhaps you haven't installed the profiling libraries for package `vector-0.10.0.1'?
    Use -v to see a list of the files searched for.
Failed to install msgpack-0.7.2.5
cabal: Error: some packages failed to install:
msgpack-0.7.2.5 failed during the building phase. The exception was:
ExitFailure 1
cabal install --reinstall msgpack  7.72s user 0.53s system 99% cpu 8.319 total

Cabal just tries to install msgpack without caring about vector - this is a big problem, what can we do about it?
Does cabal know whether a package has been installed with profiling/shared?

Still, there were some situations where a normal cabal install succeded and a parallel failed - I cannot reproduce them yet though, and the above makes it harder to find them.

Any clue?

@tibbe
Haskell member

Cabal doesn't know if a library has been installed with or without profiling support. If some version of the library exists Cabal will assume it has what it needs and not install it. This is a known problem that spans both GHC and Cabal. It requires quite a bit of work to fix I'm afraid.

@nh2
nh2 commented Feb 7, 2013

@tibbe Can you explain a bit why it would also need work on the GHC side? My first impression would be that cabal knows how things were installed - or is it because you could always install packages behind cabal's back and therefore need GHC to tell you?

@tibbe
Haskell member

@nh2 My understanding is that cabal relies on ghc-pkg for its package registration and information. Since GHC itself doesn't track the "way" a package was installed, cabal doesn't know either.

@23Skidoo
Haskell member

Closing in favor of #275.

@23Skidoo 23Skidoo closed this Mar 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment