I tried running my program which uses Haskell QuickCheck via ghc MyProgramm.hs , but received the following error:
$ ghc Ex2.hs
[1 of 1] Compiling Ex2 ( Ex2.hs, Ex2.o )
Ex2.hs:21:1: error:
Could not find module ‘Test.QuickCheck’
There are files missing in the ‘QuickCheck-2.11.3’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
|
21 | import Test.QuickCheck (
| ^^^^^^^^^^^^^^^^^^^^^^^^...
I installed stack, ran stack update and stack install QuickCheck without issue but the error persisted. Then, I ran cabal install QuickCheck and got the following errors:
$ cabal install QuickCheck
Resolving dependencies...
Configuring QuickCheck-2.12.4...
Building QuickCheck-2.12.4...
Failed to install QuickCheck-2.12.4
Build log ( /home/username/.cabal/logs/ghc-8.4.3/QuickCheck-2.12.4-3d2YDDqfPBn4BfmTJbpJXK.log ):
cabal: Entering directory '/tmp/cabal-tmp-9133/QuickCheck-2.12.4'
Configuring QuickCheck-2.12.4...
Preprocessing library for QuickCheck-2.12.4..
Building library for QuickCheck-2.12.4..
[ 1 of 16] Compiling Test.QuickCheck.Exception ( Test/QuickCheck/Exception.hs, dist/build/Test/QuickCheck/Exception.o )
[ 2 of 16] Compiling Test.QuickCheck.Random ( Test/QuickCheck/Random.hs, dist/build/Test/QuickCheck/Random.o )
Test/QuickCheck/Random.hs:10:1: error:
Could not find module ‘System.Random’
There are files missing in the ‘random-1.1’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
|
10 | import System.Random
| ^^^^^^^^^^^^^^^^^^^^
Test/QuickCheck/Random.hs:11:1: error:
Could not find module ‘System.Random.TF’
There are files missing in the ‘tf-random-0.5’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
|
11 | import System.Random.TF
| ^^^^^^^^^^^^^^^^^^^^^^^
Test/QuickCheck/Random.hs:12:1: error:
Could not find module ‘System.Random.TF.Gen’
There are files missing in the ‘tf-random-0.5’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
|
12 | import System.Random.TF.Gen(splitn)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cabal: Leaving directory '/tmp/cabal-tmp-9133/QuickCheck-2.12.4'
cabal: Error: some packages failed to install:
QuickCheck-2.12.4-3d2YDDqfPBn4BfmTJbpJXK failed during the building phase. The
exception was:
ExitFailure 1
However, I already have the arch packages haskell-random, haskell-tf-random and haskell-mwc-random installed. Does anybody know how to fix this?
Edit: I also ran cabal install random --reinstall.
Problem
On Archlinux as of 2022-09-17, pacman -S ghc cabal-install will install
system packages that provide only dynamic files (.so, .dyn_hi) in
installed packages inside /usr/lib/ghc-*; static files (.a, .hi) are (for
the most part) missing. However, the default cabal configuration enables static file
building. Unfortunately, upstream cabal-install doesn't track whether or not
static files are available inside installed packages. It just assumes they
are, and when they are gone, it fails with errors such as you have found:
[1 of 1] Compiling Main ( Main.hs, ../setup.dist/work/depender/dist/build/depender/depender-tmp/Main.o )
Main.hs:3:1: error:
Could not find module `Dynamic'
There are files missing in the `dynamic-1.0' package,
try running 'ghc-pkg check'.
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
|
| import qualified Dynamic (number)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Workaround
A quick workaround just to get up and running quickly is to disable static file
building, which is by default enabled. (Note that trying to pass package-local
flags to disable static file with e.g. --enable-shared --enable-executable-dynamic --disable-library-vanilla (which is how most if
not all current Archlinux Haskell packages seem to build packages, e.g. with
https://github.com/archlinux/svntogit-community/blob/master/haskell-scientific/trunk/PKGBUILD)
building using cabal-install may be ignored due to another, related bug; but
~/.cabal/config is a safe bet.) You may do so by adding 3 lines to
~/.cabal/config in the appropriate location:
library-vanilla: False
shared: True
executable-dynamic: True
(Alternatively, consider using alternative tools like stack.)
More complete solution
For a more long-term solution, one option involves 2 pieces: 1) one or more
system packages that provide all types of build artifacts, static and dynamic,
for the base, foundational packages (from GHC and cabal-install), at least as an option besides dynamic-only packages (secondary Haskell packages are optional,
since cabal-install can rebuild these with needed build artifacts (static or
dynamic)), and 2) patching cabal-install (and ghc-pkg, which can handle .conf
files recording information about installed packages) to track whether static
files are available, and to be aware of these when resolving dependencies so
that cabal-install knows when to prefer rebuild a source package with needed
build artifact configuration over an already installed package that doesn't
provid required build artifacts.
There is a merge request (I submitted) that provides such a patchset, called
fix-dynamic-deps, at https://github.com/haskell/cabal/pull/8461. For users
running into exactly the problem that you described (myself included), I also
created an AUR package that provides both pieces based on GHC 9.4.2 with Cabal
3.9.0.0 that includes my patchset (there is a mirror at
https://github.com/bairyn/ghc-cabal-arts.) It provides ghc and
cabal-install but includes both of these pieces.
Further reading
Here are a few more resources I wrote on or are related to this bug:
https://wiki.archlinux.org/index.php?title=Haskell&diff=745459&oldid=738269#Troubleshooting
https://github.com/haskell/cabal/pull/8461
https://github.com/bairyn/ghc-cabal-arts
https://github.com/bairyn/cabal/tree/fix-dynamic-builds
Even though I have a main = do and couldn't get it working that way, I was able to run my QuickCheck test as follows:
To run a quickCheck, first load your program with:
$ ghci MyProg.hs
Then to run the quickCheck, find the test you want to run, then run it with:
$ quickCheck my_quick_check
I depend on a package that needs alex to build, i also need ghcjs.
When i try to run stack ghci:
language-java-0.2.8: configure (lib)
Error:
-- While building package language-java-0.2.8 using:
<long command>
Process exited with code: ExitFailure 1
Logs have been written to: /Users/LeanderK/Documents/Haskell/exemplator-java_parser/.stack-work/logs/language-java-0.2.8.log
Configuring language-java-0.2.8...
Cabal-simple_mPHDZzAJ_1.24.2.0_ghcjs-0.2.1.9007019_ghc-8.0.1: The program
'alex' version >=3.1.3 is required but it could not be found.
Warning: Build failed, but optimistically launching GHCi anyway
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: exemplator-client
Using main module: 1. Package `exemplator-client' component exe:exemplator-client-exe with main-is file: ..../app/Main.hs
Progress: 1/2<command line>: cannot satisfy -package language-java-0.2.8
(use -v for more information)
I've tried: stack build alex (just returns, don't have any output. Might work), stack install alex (doesn't work).
Output of stack install alex
Couldn't find executable alex in directory .../.stack/snapshots/x86_64-osx/lts-7.19/ghcjs-0.2.1.9007019_ghc-8.0.1/bin/
For reference: This is the cabal file of the dependency, unfortunately only found on github. This is my stack and my cabal file. There is also a reddit discussion that didn't go anywhere.
I am trying to build a simple program in Haskell using stack. I created a new project using stack new and did a stack setup after that. The template builds fine.
I want to experiment with binary file parsing, so I imported Data.ByteString. My build-depends in the cabal file look like this:
build-depends: base >= 4.7 && < 5
, bytestring >= 0.10.6
, binary >= 0.7.5
stack ghci now just works, but stack build is still not happy.
Can someone tell me what I did wrong here?
Here is the complete error message:
test-0.1.0.0: build
Preprocessing library test-0.1.0.0...
In-place registering test-0.1.0.0...
Preprocessing executable 'test-exe' for test-0.1.0.0...
haskell/test/app/Main.hs:4:18:
Could not find module ‘Data.ByteString’
It is a member of the hidden package ‘bytestring-0.10.6.0#bytes_6VWy06pWzJq9evDvK2d4w6’.
Perhaps you need to add ‘bytestring’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
haskell/test/app/Main.hs:5:8:
Could not find module ‘Data.Binary.Get’
It is a member of the hidden package ‘binary-0.7.5.0#binar_3uXFWMoAGBg0xKP9MHKRwi’.
Perhaps you need to add ‘binary’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
-- While building package test-0.1.0.0 using:
.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.5.0 build lib:test exe:test-exe --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
and this is my app/Main.hs file:
module Main where
import Lib
import qualified Data.ByteString as B
import Data.Binary.Get
import Data.Word
main :: IO ()
main = do
putStrLn "f"
Thank you very much for your help.
This is likely because you added bytestring to the build-depends of the library, not the executable. One option to avoid needing to repeat these dependencies for the different stanzas is to use hpack as the package description format.
I am trying to build a simple program in Haskell using stack. I created a new project using stack new and did a stack setup after that. The template builds fine.
I want to experiment with binary file parsing, so I imported Data.ByteString. My build-depends in the cabal file look like this:
build-depends: base >= 4.7 && < 5
, bytestring >= 0.10.6
, binary >= 0.7.5
stack ghci now just works, but stack build is still not happy.
Can someone tell me what I did wrong here?
Here is the complete error message:
test-0.1.0.0: build
Preprocessing library test-0.1.0.0...
In-place registering test-0.1.0.0...
Preprocessing executable 'test-exe' for test-0.1.0.0...
haskell/test/app/Main.hs:4:18:
Could not find module ‘Data.ByteString’
It is a member of the hidden package ‘bytestring-0.10.6.0#bytes_6VWy06pWzJq9evDvK2d4w6’.
Perhaps you need to add ‘bytestring’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
haskell/test/app/Main.hs:5:8:
Could not find module ‘Data.Binary.Get’
It is a member of the hidden package ‘binary-0.7.5.0#binar_3uXFWMoAGBg0xKP9MHKRwi’.
Perhaps you need to add ‘binary’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
-- While building package test-0.1.0.0 using:
.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.5.0 build lib:test exe:test-exe --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
and this is my app/Main.hs file:
module Main where
import Lib
import qualified Data.ByteString as B
import Data.Binary.Get
import Data.Word
main :: IO ()
main = do
putStrLn "f"
Thank you very much for your help.
This is likely because you added bytestring to the build-depends of the library, not the executable. One option to avoid needing to repeat these dependencies for the different stanzas is to use hpack as the package description format.
I am trying to build a simple program in Haskell using stack. I created a new project using stack new and did a stack setup after that. The template builds fine.
I want to experiment with binary file parsing, so I imported Data.ByteString. My build-depends in the cabal file look like this:
build-depends: base >= 4.7 && < 5
, bytestring >= 0.10.6
, binary >= 0.7.5
stack ghci now just works, but stack build is still not happy.
Can someone tell me what I did wrong here?
Here is the complete error message:
test-0.1.0.0: build
Preprocessing library test-0.1.0.0...
In-place registering test-0.1.0.0...
Preprocessing executable 'test-exe' for test-0.1.0.0...
haskell/test/app/Main.hs:4:18:
Could not find module ‘Data.ByteString’
It is a member of the hidden package ‘bytestring-0.10.6.0#bytes_6VWy06pWzJq9evDvK2d4w6’.
Perhaps you need to add ‘bytestring’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
haskell/test/app/Main.hs:5:8:
Could not find module ‘Data.Binary.Get’
It is a member of the hidden package ‘binary-0.7.5.0#binar_3uXFWMoAGBg0xKP9MHKRwi’.
Perhaps you need to add ‘binary’ to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
-- While building package test-0.1.0.0 using:
.stack/setup-exe-cache/x86_64-osx/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.5.0 build lib:test exe:test-exe --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
and this is my app/Main.hs file:
module Main where
import Lib
import qualified Data.ByteString as B
import Data.Binary.Get
import Data.Word
main :: IO ()
main = do
putStrLn "f"
Thank you very much for your help.
This is likely because you added bytestring to the build-depends of the library, not the executable. One option to avoid needing to repeat these dependencies for the different stanzas is to use hpack as the package description format.