Progress messages not appearing with cabal installation for some users

I am working on a team project using Haskell and whenever I compile our project with "cabal install" I start to see the following:

$ cabal clean && cabal install
cleaning...
Resolving dependencies...
Configuring hackathon-0.1...
Building hackathon-0.1...
Preprocessing executable 'hackathon' for hackathon-0.1...
[ 1 of 65] Compiling Data.MaybeUtil   ( src/Data/MaybeUtil.hs, dist/dist-sandbox-52369b17/build/hackathon/hackathon-tmp/Data/MaybeUtil.o )
[ 2 of 65] Compiling Data.JQL         ( src/Data/JQL.hs, dist/dist-sandbox-52369b17/build/hackathon/hackathon-tmp/Data/JQL.o )
[ 3 of 65] Compiling Data.Tuples      ( src/Data/Tuples.hs, dist/dist-sandbox-52369b17/build/hackathon/hackathon-tmp/Data/Tuples.o )
...
$

      

However, my team members see:

$ cabal clean && cabal install
cleaning...
Resolving dependencies...
Configuring hackathon-0.1...
Building hackathon-0.1...
Installed hackathon-0.1

      

What is the difference between their configuration, they do not see all "Progress" messages starting with [X of N] My.Module?

I would really like them to be able to see the progress of the compilation as it happens as our project is quite large and currently has 65 modules and is growing. Hooray!

+3


source to share


2 answers


Ok, I decided to just look at the source code and answer my own question. After diving through the installation and completion source code inside the GHC source, I eventually found what I was looking for at the bottom of compiler / main / HscMain.hs

showModuleIndex :: (Int, Int) -> String
showModuleIndex (i,n) = "[" ++ padded ++ " of " ++ n_str ++ "] "
  where
    n_str = show n
    i_str = show i
    padded = replicate (length n_str - length i_str) ' ' ++ i_str

      

This is the method that prints the index of the module. It is used inside the batchMsg function , which wraps it with the compilationProgressMessage method :

compilationProgressMsg :: DynFlags -> String -> IO ()
compilationProgressMsg dflags msg
  = ifVerbose dflags 1 $
    logOutput dflags defaultUserStyle (text msg)

      

As you can see, this method only prints things to the log output stream if the verbosity is one or more.



So, I just tried to do this in my terminal:

cabal install -j4 -v1

      

And then if I close the .cabal-sandbox / logs / package-name.log file, I can see the modules indexed by compilation messages. I think this solves this problem. Then, when compilation finishes (or errors), all module messages are printed to stdout. It seems like something is blocking print calls to stdout in parallel compilation in GHC. There is also something that sets verbosity to 0 when parallel compilation is enabled. I think both of these are bugs and need to be fixed, so I can go and try and raise feature requests now.

Anyway, I hope this investigation helps someone else as well. Cheers and thanks for all pointers!

+1


source


When you do cabal install

multithreading ( -j2

and above), compilation of one file doesn't appear on stdout

, but should still be written to the log file.



+3


source







All Articles