Error installing the shuffle library with stack - haskell

Using stack 1.2.0 and LTS 7.0 I'm getting the following error installing the shuffle library:
$ cabal get shuffle
$ cd shuffle-0.1.3.3
$ stack build
...
/tmp/shuffle-0.1.3.3/Setup.hs:2:1: error:
Failed to load interface for ‘Distribution.Simple.UUAGC’
Perhaps you meant
Distribution.Simple.UHC (from Cabal-1.24.0.0)
Distribution.Simple.GHC (from Cabal-1.24.0.0)
Distribution.Simple.JHC (from Cabal-1.24.0.0)
Use -v to see a list of the files searched for.
/tmp/shuffle-0.1.3.3/Setup.hs:3:1: error:
Failed to load interface for ‘UU.UUAGC’
Use -v to see a list of the files searched for.
-- While building package shuffle-0.1.3.3 using:
/usr/local/bin/ghc --make -odir /tmp/shuffle-0.1.3.3/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup -hidir /tmp/shuffle-0.1.3.3/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup -i -i. -package=Cabal-1.24.0.0 -clear-package-db -global-package-db -package-db=/home/asr/.stack/snapshots/x86_64-linux/lts-7.0/8.0.1/pkgdb /tmp/shuffle-0.1.3.3/Setup.hs -o /tmp/shuffle-0.1.3.3/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup/setup
Process exited with code: ExitFailure 1
I'm using the following stack.yaml file:
resolver: lts-7.0
# Local packages, usually specified by relative directory name
packages:
- '.'
extra-deps:
- logict-state-0.1.0.2
- pqueue-1.3.1.1
- uhc-util-0.1.6.6
- uuagc-0.9.52.1
- uuagc-cabal-1.0.6.0
- uulib-0.9.22
Do I need to add/change something in the library or in stack.yaml? (I had no problems using cabal-install).

I was able to get this to work by adding the following to stack.yaml:
explicit-setup-deps:
shuffle: true
For more information, see: https://docs.haskellstack.org/en/stable/yaml_configuration/#explicit-setup-deps

It appears that this package requires you to have installed uuagc-cabal to build it. Starting after Cabal-1.23 these kinds of package dependencies for Setup.hs files can be captured in the custom-setup section of a cabal file.
There are tickets about this functionality for stack that seem to be interlinked from here:
Setup.hs cannot use local snapshot dependencies WAS stack failing to resolve local dependencies of multiple package project #897

Related

Haskell there are files missing in the QuickCheck-2.11.3 package

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

Haskell Stack failing to install easyrender

I have GHC 8.0.2 installed on a Haskell stack, and I need a certain number of packages on it for my project, one being easyrender.
I install it using the following command, which works for all other package installations:
stack install easyrender
I get the following output:
easyrender-0.1.1.2: configure
-- While building package easyrender-0.1.1.2 using:
/home/nathan/.stack/programs/x86_64-linux/ghc-8.0.2/bin/ghc --make -odir /tmp/stack5987/easyrender-0.1.1.2/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup -hidir /tmp/stack5987/easyrender-0.1.1.2/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup -i -i. -clear-package-db -global-package-db -package-db=/home/nathan/.stack/snapshots/x86_64-linux/ghc-8.0.2/8.0.2/pkgdb -package-db=/home/nathan/.stack/global-project/.stack-work/install/x86_64-linux/ghc-8.0.2/8.0.2/pkgdb -hide-all-packages -package-id=base-4.9.1.0 -package-id=superdoc-0.1.2.5-9gGVGYAJpHrGct376cUN41 -optP-include -optP/tmp/stack5987/easyrender-0.1.1.2/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/setup_macros.h /tmp/stack5987/easyrender-0.1.1.2/Setup.hs /home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -main-is StackSetupShim.mainOverride -o /tmp/stack5987/easyrender-0.1.1.2/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/setup -threaded
Process exited with code: ExitFailure 1
Logs have been written to: /home/nathan/.stack/global-project/.stack-work/logs/easyrender-0.1.1.2.log
[1 of 2] Compiling Main ( /tmp/stack5987/easyrender-0.1.1.2/Setup.hs, /tmp/stack5987/easyrender-0.1.1.2/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/Main.o )
[2 of 2] Compiling StackSetupShim ( /home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /tmp/stack5987/easyrender-0.1.1.2/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup/StackSetupShim.o )
/home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs:3:1: error:
Failed to load interface for ‘Distribution.PackageDescription’
It is a member of the hidden package ‘Cabal-2.0.1.0’.
It is a member of the hidden package ‘Cabal-1.24.2.0’.
Use -v to see a list of the files searched for.
/home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs:4:1: error:
Failed to load interface for ‘Distribution.Simple’
It is a member of the hidden package ‘Cabal-2.0.1.0’.
It is a member of the hidden package ‘Cabal-1.24.2.0’.
Use -v to see a list of the files searched for.
/home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs:5:1: error:
Failed to load interface for ‘Distribution.Simple.Build’
It is a member of the hidden package ‘Cabal-2.0.1.0’.
It is a member of the hidden package ‘Cabal-1.24.2.0’.
Use -v to see a list of the files searched for.
/home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs:6:1: error:
Failed to load interface for ‘Distribution.Simple.Setup’
It is a member of the hidden package ‘Cabal-2.0.1.0’.
It is a member of the hidden package ‘Cabal-1.24.2.0’.
Use -v to see a list of the files searched for.
/home/nathan/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs:7:1: error:
Failed to load interface for ‘Distribution.Simple.LocalBuildInfo’
It is a member of the hidden package ‘Cabal-2.0.1.0’.
It is a member of the hidden package ‘Cabal-1.24.2.0’.
Use -v to see a list of the files searched for.
Since Cabal seems to be a problem, I tried running stack install Cabal, but that doesn't do anything. The log file referenced just says the same thing as the output.
Ideas?
Nathan
This is a bug in the easyrender package description. Note that cabal-install's "new-build" encounters the same problem. See my comment on this stack issue: https://github.com/commercialhaskell/stack/issues/3560#issuecomment-344075524
Workaround is as described by Thomas's answer, and also in the issue at https://github.com/commercialhaskell/stack/issues/3560#issuecomment-343980627
The next stack release will emit a warning about this circumstance, which should reduce confusion in the future.
Unfortunately, easyrender does not have an issue tracker, it appears to only have a hackage page. I have emailed the author requesting that he fix this.
No such problems with cabal-install:
% cabal install easyrender
Resolving dependencies...
Downloading superdoc-0.1.2.5...
Configuring superdoc-0.1.2.5...
Building superdoc-0.1.2.5...
Installed superdoc-0.1.2.5
Downloading easyrender-0.1.1.2...
Configuring easyrender-0.1.1.2...
Building easyrender-0.1.1.2...
Installed easyrender-0.1.1.2
So I'm guessing this is an issue with stack handling non-simple builds in a different manner. Namely, cabal-install seems to assume Cabal is a dependency of the setup.hs while stack does not.
Just to check, I tried and could produce your same issue but adding Cabal to the setup-depends: line of the easyrender.cabal made it work fine.

Using Build-Tools (Alex) with Stack and GHCjs

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.

Stack can't find libgfortran-3.dll when trying to build with hmatrix

I am trying to setup hmatrix on my Windows 10 machine with GHC 8.0.2.
I was following the answer here but when I try to build it says that it cannot find libgfortran-3.dll although I am sure I added it to the bin folder in the BLAS directory.
My code is in here
I run stack build and this is what I get:
hmatrix-0.18.0.0: configure
Progress: 1/2
-- While building package hmatrix-0.18.0.0 using:
C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.2.exe --builddir=.stack-work\dist\ca59d0ab configure "--with-ghc=C:\\Program Files\\Haskell Platform\\8.0.2\\bin\\ghc.EXE" "--with-ghc-pkg=C:\\Program Files\\Haskell Platform\\8.0.2\\bin\\ghc-pkg.EXE" --user --package-db=clear --package-db=global --package-db=C:\sr\snapshots\b201cfe6\pkgdb --package-db=D:\Haskell\networks\.stack-work\install\65995373\pkgdb --libdir=D:\Haskell\networks\.stack-work\install\65995373\lib --bindir=D:\Haskell\networks\.stack-work\install\65995373\bin --datadir=D:\Haskell\networks\.stack-work\install\65995373\share --libexecdir=D:\Haskell\networks\.stack-work\install\65995373\libexec --sysconfdir=D:\Haskell\networks\.stack-work\install\65995373\etc --docdir=D:\Haskell\networks\.stack-work\install\65995373\doc\hmatrix-0.18.0.0 --htmldir=D:\Haskell\networks\.stack-work\install\65995373\doc\hmatrix-0.18.0.0 --haddockdir=D:\Haskell\networks\.stack-work\install\65995373\doc\hmatrix-0.18.0.0 --dependency=array=array-0.5.1.1 --dependency=base=base-4.9.1.0 --dependency=binary=binary-0.8.3.0 --dependency=bytestring=bytestring-0.10.8.1 --dependency=deepseq=deepseq-1.4.2.0 --dependency=random=random-1.1-9tceXaeYIMZ4JrKq20Egog --dependency=split=split-0.2.3.1-FWyXC6nhV0H3AfM8IzrEFk --dependency=storable-complex=storable-complex-0.2.2-G9QzpmZTKvgKKVagrcRWdL --dependency=vector=vector-0.11.0.0-HhutbadagxHIONIkSRJEug -fopenblas --extra-include-dirs=C:\OpenBLAS-v0.2.19-Win64-int32\include --extra-include-dirs=C:\Users\Yotam\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include --extra-lib-dirs=C:\OpenBLAS-v0.2.19-Win64-int32\bin --extra-lib-dirs=C:\Users\Yotam\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\lib
Process exited with code: ExitFailure 1
Logs have been written to: D:\Haskell\networks\.stack-work\logs\hmatrix-0.18.0.0.log
Configuring hmatrix-0.18.0.0...
Cabal-simple_Z6RU0evB_1.24.2.0_ghc-8.0.2.exe: Missing dependency on a foreign
library:
* Missing C library: libgfortran-3
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
D:\OpenBLAS-v0.2.19-Win64-int32\bin includes both libopenblas.dll and libgfortran-3.dll and the blas directory was taken from this url
Thanks for any help
I've managed to install it as follows.
In yourpath\to\stack\x86_64-windows\msys2-20150512, open a msys2 shell by double-clicking on msys2_shell.bat.
In the shell, type:
pacman -S mingw-w64-x86_64-toolchain
Then add these "extra" in stack.yaml:
extra-include-dirs:
- yourpath\to\OpenBLAS\include
extra-lib-dirs:
- yourpath\to\OpenBLAS\lib
- yourpath\to\stack\x86_64-windows\msys2-20150512\usr\lib\gcc\x86_64-pc-msys\6.3.0
- yourpath\to\stack\x86_64-windows\msys2-20150512\mingw64\bin

stack --nix build complains about ghc version mismatch

When building threepenny-gui on NixOS with stack --nix build, I got error saying I have the wrong version of ghc. Then I tried stack --nix setup, which doesn't run because bash is on an unexpected path on NixOS (that's expected, since the stack documentation only mentions stack --nix build not setup). What am I missing?
FYI, to deal with the zlib issues I have also added a shell.nix and default.nix per https://github.com/commercialhaskell/stack/issues/2130
EDIT: was able to build with the method suggested by mkkeankylej from the above link, i.e. editing ~/.stack/config.yaml and add zlib to buildInputs in shell.nix But I'd still like to know if there's a way to do it w/o falling back to nix-shell? It sounds like stack --nix build should work as long as the nix-shell method does.
First of all, threepenny-gui seems to provide no stack.yaml, i.e. the project isn't configured to be built with stack. Thus, I wonder why you even bother using stack since that is not going to be any easier than building the project with cabal-install or even Nix directly. The easiest and fastest way is probably to configure the build by running:
$ nix-shell "<nixpkgs>" -A haskellPackages.threepenny-gui.env --run "cabal configure"
Afterwards, you can simply "cabal build" the project and work with it (inside or outside of a nix-shell) as you please; the compiler and all necessary build dependencies are provided by Nix.
If you don't want that, then you can use the normal cabal-install approach:
$ cabal sandbox init
$ cabal install --only-dependencies
$ cabal configure
$ cabal build
That build is probably going to require system libraries, like libz, so you must make sure that those are available. There's a million different ways to accomplish that, but the cleanest IMHO is the following:
$ zlibinc=$(nix-build --no-out-link "<nixpkgs>" -A zlib.dev)
$ zliblib=$(nix-build --no-out-link "<nixpkgs>" -A zlib.out)
$ cabal install --only-dependencies --extra-include-dirs=$zlibinc --extra-lib-dirs=$zliblib
Last but not least, it's not obvious to me why your stack build --nix command won't succeed, because that command will use Nix to install the proper version of GHC automatically. So if that doesn't work, then my best guess is that you're using an old version of stack where that feature doesn't work properly. I've tried that build using the stack binary that Nix provides, stack 1.3.2, and it can compile a current git checkout of threepenny-gui just fine:
$ git clone git://github.com/HeinrichApfelmus/threepenny-gui.git
Cloning into 'threepenny-gui'...
remote: Counting objects: 4102, done.
remote: Total 4102 (delta 0), reused 0 (delta 0), pack-reused 4101
Receiving objects: 100% (4102/4102), 1.88 MiB | 581.00 KiB/s, done.
Resolving deltas: 100% (2290/2290), done.
$ cd threepenny-gui
$ stack init
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- threepenny-gui.cabal
Selecting the best among 9 snapshots...
* Partially matches lts-7.16
websockets-snap not found
- threepenny-gui requires >=0.8 && <0.11
Using package flags:
- threepenny-gui: buildexamples = False, network-uri = True, rebug = False
* Matches nightly-2017-01-17
Selected resolver: nightly-2017-01-17
Initialising configuration using resolver: nightly-2017-01-17
Total number of user packages considered: 1
Writing configuration to file: stack.yaml
All done.
$ stack build --nix --nix-packages zlib
threepenny-gui-0.7.1.0: configure (lib)
Configuring threepenny-gui-0.7.1.0...
threepenny-gui-0.7.1.0: build (lib)
Preprocessing library threepenny-gui-0.7.1.0...
[...]
Registering threepenny-gui-0.7.1.0...
This works without any specially edited config files for nix-shell, nor does it require special customization of stack.

Resources