Building project dependent on gtk2hs fails on lts-7.8 and later - haskell

Building project dependent on glib fails on lts-7.8 and later after Cabal becomes 1.24.1.0.
Steps to reproduce
Add glib to a project's .cabal file
build-depends: base
, gtktest
, glib
Run following commands
stack install gtk2hs-buildtools
stack build
Result
The following error occurred
...
[debug] Ignoring package Cabal due to wanting version 1.24.1.0 instead of 1.24.0.0
#(Stack\Build\Installed.hs:196:5)
...
-- While building package glib-0.13.4.1 using:
C:\Users\foo\AppData\Local\Programs\stack\x86_64-windows\ghc-8.0.1\bin\ghc.EXE --make -odir C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\.stack-work\dist\b7fec021\setup -hidir C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\.stack-work\dist\b7fec021\setup -i -i. -package=Cabal-1.24.0.0 -clear-package-db -global-package-db -package-db=C:\sr\snapshots\a78c6a89\pkgdb C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\Setup.hs -o C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\.stack-work\dist\b7fec021\setup\setup
Process exited with code: ExitFailure 1
Logs have been written to: C:\Users\foo\Documents\Files\Haskell\gtktest\.stack-work\logs\glib-0.13.4.1.log
[1 of 1] Compiling Main ( C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\Setup.hs, C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\.stack-work\dist\b7fec021\setup\Main.o )
C:\Users\foo\AppData\Local\Temp\stack5512\glib-0.13.4.1\Setup.hs:8:29: error:
Couldn't match expected type ‘Distribution.Simple.UserHooks.UserHooks’
with actual type ‘Cabal-1.24.1.0:Distribution.Simple.UserHooks.UserHooks’
NB: Cabal-1.24.1.0:Distribution.Simple.UserHooks.UserHooks’
is defined in ‘Distribution.Simple.UserHooks’
in package ‘Cabal-1.24.1.0’
‘Distribution.Simple.UserHooks.UserHooks’
is defined in ‘Distribution.Simple.UserHooks’
in package ‘Cabal-1.24.0.0’
In the first argument of ‘defaultMainWithHooks’, namely
gtk2hsUserHooks’
In the expression: defaultMainWithHooks gtk2hsUserHooks
In an equation for ‘main’:
main = defaultMainWithHooks gtk2hsUserHooks
I thought that Cabal-1.24.0.0 in the ghc-8.0.1 global package was causing problems, and succeeded building it after installing Cabal-1.24.1.0 in ghc 's global package.
However, this method is difficult for beginners and I do not think the right solution. How is the correct way to solve it?
Stack version
Version 1.2.0, Git revision 123819b7d65df2ad7fe63fb5eb39a98536acb5f3 (4055 commits) x86_64 hpack-0.14.0

Related

Installing Euterpea for computer music applications and Haskell

I followed the instructions here http://www.euterpea.com for installing Euterpea (a domain-specific language for computer music applications embedded in Haskell), and I received a message that certain packages and things failed to install (see the code below). How can I install the remaining packages?
Mo-MacBook-Pro:~ Mo$ cabal update
Downloading the latest package list from hackage.haskell.org
cabal install Euterpea
To revert to previous state run:
cabal update --index-state='2018-06-25T08:34:14Z'
Mo-MacBook-Pro:~ Mo$ cabal install Euterpea
clang: warning: argument unused during compilation: '-nopie' [-Wunused-
command-line-argument]
Resolving dependencies...
Downloading heap-1.0.4...
Downloading PortMidi-0.1.6.1...
Configuring PortMidi-0.1.6.1...
Downloading lazysmallcheck-0.6...
Configuring heap-1.0.4...
Downloading semigroups-0.18.5...
Configuring lazysmallcheck-0.6...
Configuring semigroups-0.18.5...
Building heap-1.0.4...
Building PortMidi-0.1.6.1...
Building lazysmallcheck-0.6...
Building semigroups-0.18.5...
Installed semigroups-0.18.5
Downloading stm-2.5.0.0...
Configuring stm-2.5.0.0...
Installed lazysmallcheck-0.6
Downloading HCodecs-0.5.1...
Installed heap-1.0.4
Downloading Stream-0.4.7.2...
Configuring HCodecs-0.5.1...
Configuring Stream-0.4.7.2...
Building stm-2.5.0.0...
Building HCodecs-0.5.1...
Building Stream-0.4.7.2...
Failed to install HCodecs-0.5.1
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/HCodecs-0.5.1-
BtnY8oBJJ5FGnsoQaqbvOm.log ):
cabal: Entering directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5294/HCodecs-0.5.1'
Configuring HCodecs-0.5.1...
clang: warning: argument unused during compilation: '-nopie' [-Wunused-
command-line-argument]
Preprocessing library for HCodecs-0.5.1..
Building library for HCodecs-0.5.1..
<command line>: cannot satisfy -package-id random-1.1-
7T1TXpwb46H1j0av1OnVaD
(use -v for more information)
cabal: Leaving directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5294/HCodecs-0.5.1'
Failed to install Stream-0.4.7.2
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/Stream-0.4.7.2-
ES6rey5IgWg9tsXDghlP7Y.log ):
cabal: Entering directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5295/Stream-0.4.7.2'
Warning: Stream.cabal:6:4: Tabs used as indentation at 6:4, 12:4, 13:4,
14:4,
15:4, 16:4, 17:4
Configuring Stream-0.4.7.2...
clang: warning: argument unused during compilation: '-nopie' [-Wunused-
command-line-argument]
Preprocessing library for Stream-0.4.7.2..
Building library for Stream-0.4.7.2..
<command line>: cannot satisfy -package-id QuickCheck-2.11.3-
4Q6LQ7mN6Tj8otrLuHN0se
(use -v for more information)
cabal: Leaving directory
'/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-
5295/Stream-0.4.7.2'
Installed PortMidi-0.1.6.1
Installed stm-2.5.0.0
cabal: Error: some packages failed to install:
Euterpea-2.0.6-LLo28S848YneLemh6QUkK depends on Euterpea-2.0.6 which
failed to
install.
HCodecs-0.5.1-BtnY8oBJJ5FGnsoQaqbvOm failed during the building phase.
The
exception was:
ExitFailure 1
Stream-0.4.7.2-ES6rey5IgWg9tsXDghlP7Y failed during the building phase.
The
exception was:
ExitFailure 1
arrows-0.4.4.2-GLke2GgDEro6Tzj3MGmTOB depends on arrows-0.4.4.2 which
failed
to install.
It would be great if someone could help. Thanks.
I have included all the code, lest some particular relevant detail was omitted.
Edit
I have also tried to install Euterpea via stack. I get this message:
Mo-MacBook-Pro:~ Mo$ stack install Euterpea
Error: While constructing the build plan, the following exceptions were
encountered:
In the dependencies for Euterpea-2.0.6:
PortMidi must match ==0.1.6.1, but the stack configuration has no specified version (latest matching version is 0.1.6.1)
arrows must match >=0.4 && <0.5, but the stack configuration has no specified version (latest matching version is 0.4.4.2)
needed since Euterpea is a build target.
Some different approaches to resolving this:
* Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be convenient when dealing with many complicated constraint
errors, but results may be unpredictable.
* Recommended action: try adding the following to your extra-deps in /Users/Mo/.stack/global-project/stack.yaml:
- PortMidi-0.1.6.1
- arrows-0.4.4.2
Plan construction failed.
--
Edit 2.
As suggested below, I tried cabal install random-1.1 --force-reinstalls which generated:
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Resolving dependencies...
Warning: The following packages are likely to be broken by the reinstalls:
tf-random-0.5
QuickCheck-2.11.3
Continuing even though the plan contains dangerous reinstalls.
Configuring random-1.1...
Building random-1.1...
Installed random-1.1
Then
Mo-MacBook-Pro:~ Mo$ cabal install Euterpea
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Resolving dependencies...
Configuring Stream-0.4.7.2...
Configuring HCodecs-0.5.1...
Building HCodecs-0.5.1...
Building Stream-0.4.7.2...
Failed to install HCodecs-0.5.1
Build log ( /Users/lukeburke/.cabal/logs/ghc-8.4.3/HCodecs-0.5.1- BtnY8oBJJ5FGnsoQaqbvOm.log ):
cabal: Entering directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20742/HCodecs- 0.5.1'
Configuring HCodecs-0.5.1...
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Preprocessing library for HCodecs-0.5.1..
Building library for HCodecs-0.5.1..
<command line>: cannot satisfy -package-id random-1.1- 7T1TXpwb46H1j0av1OnVaD
(use -v for more information)
cabal: Leaving directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20742/HCodecs- 0.5.1'
Failed to install Stream-0.4.7.2
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/Stream-0.4.7.2- ES6rey5IgWg9tsXDghlP7Y.log ):
cabal: Entering directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20743/Stream- 0.4.7.2'
Warning: Stream.cabal:6:4: Tabs used as indentation at 6:4, 12:4, 13:4, 14:4,
15:4, 16:4, 17:4
Configuring Stream-0.4.7.2...
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Preprocessing library for Stream-0.4.7.2..
Building library for Stream-0.4.7.2..
<command line>: cannot satisfy -package-id QuickCheck-2.11.3- 4Q6LQ7mN6Tj8otrLuHN0se
(use -v for more information)
cabal: Leaving directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-20743/Stream- 0.4.7.2'
cabal: Error: some packages failed to install:
Euterpea-2.0.6-LLo28S848YneLemh6QUkK depends on Euterpea-2.0.6 which failed to
install.
HCodecs-0.5.1-BtnY8oBJJ5FGnsoQaqbvOm failed during the building phase. The
exception was:
ExitFailure 1
Stream-0.4.7.2-ES6rey5IgWg9tsXDghlP7Y failed during the building phase. The
exception was:
ExitFailure 1
arrows-0.4.4.2-GLke2GgDEro6Tzj3MGmTOB depends on arrows-0.4.4.2 which failed
to install.
Edit 3
It has been suggested below that multiple packages are botched and that I should try re-installing all of them (in a single command, i.e. cabal install random tf-random QuickCheck Euterpea --force-reinstalls.
However, if I write cabal install random tf-random QuickCheck Euterpea --force-reinstalls I receive the following code:
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Resolving dependencies...
Warning: The following packages are likely to be broken by the reinstalls:
QuickCheck-2.11.3
Continuing even though the plan contains dangerous reinstalls.
Downloading erf-2.0.0.0...
Configuring random-1.1...
Configuring erf-2.0.0.0...
Building random-1.1...
Building erf-2.0.0.0...
Installed erf-2.0.0.0
Installed random-1.1
Downloading tf-random-0.5...
Configuring tf-random-0.5...
Building tf-random-0.5...
Failed to install tf-random-0.5
Build log ( /Users/Mo/.cabal/logs/ghc-8.4.3/tf-random-0.5- ADZoyzEXgHe6hyR0Bycce0.log ):
cabal: Entering directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-21584/tf- random-0.5'
Configuring tf-random-0.5...
clang: warning: argument unused during compilation: '-nopie' [- Wunused-command-line-argument]
Preprocessing library for tf-random-0.5..
Building library for tf-random-0.5..
<command line>: cannot satisfy -package-id primitive-0.6.4.0- 9k41Y6ToOAE8KXK6VMGV2O
(use -v for more information)
cabal: Leaving directory '/var/folders/dy/q51p3v595kbd8_wclmt80v700000gn/T/cabal-tmp-21584/tf- random-0.5'
cabal: Error: some packages failed to install:
Euterpea-2.0.6-87WYqltNL8w8teqXOsc4TL depends on Euterpea-2.0.6 which failed
to install.
HCodecs-0.5.1-DrGKEnNk6EBHti2goL6KP5 depends on HCodecs-0.5.1 which. failed to
install.
QuickCheck-2.12.6.1-KuXpgimNOXzF2SmGPEs5LR depends on QuickCheck- 2.12.6.1
which failed to install.
Stream-0.4.7.2-FedzVSwUnWMDxlzmPNWt7x depends on Stream-0.4.7.2 which failed
to install.
arrows-0.4.4.2-EGvZPpby4BcD99TcXDoCg4 depends on arrows-0.4.4.2 which. failed
to install.
tf-random-0.5-ADZoyzEXgHe6hyR0Bycce0 failed during the building phase. The
exception was:
ExitFailure 1
What can I do to install Euterpea?
Installing the Euterpea package
This answer uses LTS 12.26 as I've verified it works, but this should work for most LTS releases (see bottom of step 2 for details).
Make a new Stack project:
stack new euter-test
cd euter-test
Edit stack.yaml and set the LTS to 12.26 and extra-deps to specify the versions of packages that aren't present in the LTS but are present on Hackage:
resolver: lts-12.26
...
extra-deps:
- Euterpea-2.0.6
- PortMidi-0.1.6.1
- arrows-0.4.4.2
- Stream-0.4.7.2
- lazysmallcheck-0.6
The errors you were getting on the Stack install ("PortMidi must match ==0.1.6.1, but the stack configuration has no specified version") indicate that a package you're using requires a particular version of a library, but the package repository (LTS snapshot) doesn't contain that library, so you need to specify it explicitly. Stack then prints which library and version is missing, so you can just keep trying stack build and adding the libraries until the build succeeds.
We use LTS 12.26 here, but by adding the extra-deps packages as described above, you should be able to get it working on any LTS.
Edit package.yaml and add Euterpea to the list of dependencies:
dependencies:
...
- Euterpea
A simple test in app/Main.hs:
module Main where
import Euterpea
main :: IO ()
main = play $ c 4 qn
Run stack build:
lazysmallcheck-0.6: download
heap-1.0.4: download
heap-1.0.4: configure
HCodecs-0.5.1: download
PortMidi-0.1.6.1: download
heap-1.0.4: build
lazysmallcheck-0.6: configure
lazysmallcheck-0.6: build
HCodecs-0.5.1: configure
HCodecs-0.5.1: build
PortMidi-0.1.6.1: configure
heap-1.0.4: copy/register
lazysmallcheck-0.6: copy/register
PortMidi-0.1.6.1: build
Stream-0.4.7.2: download
Stream-0.4.7.2: configure
Stream-0.4.7.2: build
Stream-0.4.7.2: copy/register
PortMidi-0.1.6.1: copy/register
arrows-0.4.4.2: download
arrows-0.4.4.2: configure
arrows-0.4.4.2: build
arrows-0.4.4.2: copy/register
HCodecs-0.5.1: copy/register
Euterpea-2.0.6: download
Euterpea-2.0.6: configure
Euterpea-2.0.6: build
Euterpea-2.0.6: copy/register
Building all executables for `euter' once. After a successful build of all of them, only specified executables will be rebuilt.
euter-0.1.0.0: configure (lib + exe)
Configuring euter-0.1.0.0...
euter-0.1.0.0: build (lib + exe)
Preprocessing library for euter-0.1.0.0..
Building library for euter-0.1.0.0..
[1 of 2] Compiling Lib ( src/Lib.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Lib.o )
[2 of 2] Compiling Paths_euter ( .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/autogen/Paths_euter.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/Paths_euter.o )
Preprocessing executable 'euter-exe' for euter-0.1.0.0..
Building executable 'euter-exe' for euter-0.1.0.0..
[1 of 2] Compiling Main ( app/Main.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/euter-exe-tmp/Main.o )
[2 of 2] Compiling Paths_euter ( .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/autogen/Paths_euter.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/euter-exe-tmp/Paths_euter.o )
Linking .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/euter-exe/euter-exe ...
euter-0.1.0.0: copy/register
Installing library in <...>
Installing executable euter-exe in <...>
Registering library for euter-0.1.0.0..
Running the executable produced by the project should emit a tone if you're running a MIDI synthesiser:
stack exec euter-test-exe
Troubleshooting
If you get an error like *** Exception: No MIDI outputs!, then you're not running a MIDI synthesiser (see below). Make sure you run it in the background (eg. in another terminal).
If you don't get an error but there's no audio output, try running devices in GHCI to see what outputs are available, and then use playDev x instead of play, where x is the OutputDeviceID of the synth input port. Eg:
> devices
Input devices:
InputDeviceID 1 Midi Through Port-0
Output devices:
OutputDeviceID 0 Midi Through Port-0
OutputDeviceID 2 Synth input port (25952:0)
> playDev 2 $ c 4 qn
If you run devices and don't see any synth input ports, but you have fluidsynth running in the background, then you might need to restart ghci and try again.
Running a MIDI synthesiser
Here's a quick step-by-step to get Fluidsynth running on Debian (with guesses at a Mac setup along the way).
Install fluidsynth:
On Debian this is sudo apt install fluidsynth, on mac it could be brew install fluidsynth - there's quite a few articles on how to do this, just google it if in doubt.
Run fluidsynth:
On Debian using ALSA this is
fluidsynth -s -a alsa -m alsa_seq /usr/share/sounds/sf2/FluidR3_GM.sf2
Instructing fluidsynth to run in server mode, use alsa as the audio driver and alsa_seq as the MIDI driver, and use the soundfont FluidR3_GM.sf2 (should be installed as part of the fluidsynth install).
On Mac, it seems like the correct commandline is:
fluidsynth -s -a coreaudio -m coremidi /usr/share/sounds/sf2/FluidR3_GM.sf2
If you can't find the FluidR3_GM.sf2 file then it's likely it's been installed in a different location. As a last resort, you can just download a soundfont file and use that rather than the one provided by FluidSynth.
After running this, you should be given a prompt and maybe a few warnings, and fluidsynth will be running. Make sure it's running before using Euterpea, and keep it running while using Euterpea.

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.

Compiling Haskell to JavaScript using GHCJS and Haskell Stack

How can Haskell be compiled to Javascript using GHCJS and Haskell Stack?
I have the current version of Haksell Stack 1.5.1.
I can initialize a GHCJS project with this command: stack new ghcjsSetup ghcjs
Once in the project directory I try following the Stack documentation for GHCJS.
I create a stack.yaml file and edit it to match the example from the documentation so that is looks like this.
resolver: lts-7.19
compiler: ghcjs-0.2.1.9007019_ghc-8.0.1
compiler-check: match-exact
setup-info:
ghcjs:
source:
ghcjs-0.2.1.9007019_ghc-8.0.1:
url: http://ghcjs.tolysz.org/ghc-8.0-2017-02-05-lts-7.19-9007019.tar.gz
sha1: d2cfc25f9cda32a25a87d9af68891b2186ee52f9
Following the documentation further I try to install and boot GHCJS with this command:
stack setup
This command produces an output which ends with an error.
Preparing to install GHCJS to an isolated location.
This will not interfere with any system-level installation.
Preparing to download ghcjs-0.2.1.9007019_ghc-8.0.1 ...
Already downloaded.
Unpacking GHCJS into /home/u/.stack/programs/x86_64-linux/ghcjs-0.2.1.9007019_ghc-8.0.1/src/ ...
Setting up GHCJS build environment
Installing GHCJS (this will take a long time) ...
ghcjs-0.2.1.9007019: configure (lib + exe)
Package ghcjs uses a custom Cabal build, but does not use a custom-setup stanza
Using the explicit setup deps approach based on configuration
Strongly recommend fixing the package's cabal file
[1 of 2] Compiling Main ( /home/u/.stack/programs/x86_64-linux/ghcjs-0.2.1.9007019_ghc-8.0.1/src/Setup.hs, /home/u/.stack/programs/x86_64-linux/ghcjs-0.2.1.9007019_ghc-8.0.1/src/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup/Main.o )
[2 of 2] Compiling StackSetupShim ( /home/u/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs, /home/u/.stack/programs/x86_64-linux/ghcjs-0.2.1.9007019_ghc-8.0.1/src/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup/StackSetupShim.o )
Linking /home/u/.stack/programs/x86_64-linux/ghcjs-0.2.1.9007019_ghc-8.0.1/src/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup/setup ...
Configuring ghcjs-0.2.1.9007019...
ghcjs-0.2.1.9007019: build (lib + exe)
Preprocessing library ghcjs-0.2.1.9007019...
/home/u/.stack/programs/x86_64-linux/ghcjs-0.2.1.9007019_ghc-8.0.1/src/src/Compiler/JMacro/Base.hs:1:55: warning:
-XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
/home/u/.stack/programs/x86_64-linux/ghcjs-0.2.1.9007019_ghc-8.0.1/src/src/Compiler/JMacro/QQ.hs:1:55: warning:
-XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
[ 1 of 50] Compiling GHCJS.Prim.TH.Serialized ( lib/ghcjs-prim/GHCJS/Prim/TH/Serialized.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/GHCJS/Prim/TH/Serialized.o )
Because it is too long to post here I have excluded the middle of the output. Which includes lots of warning messages.
[49 of 50] Compiling Compiler.Program ( src/Compiler/Program.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/Compiler/Program.o )
[50 of 50] Compiling GHCJS ( src/GHCJS.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/GHCJS.o )
Preprocessing executable 'ghcjs' for ghcjs-0.2.1.9007019...
[1 of 1] Compiling Main ( src-bin/Main.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/ghcjs/ghcjs-tmp/Main.o )
Linking .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/ghcjs/ghcjs ...
Preprocessing executable 'ghcjs-boot' for ghcjs-0.2.1.9007019...
[1 of 1] Compiling Main ( src-bin/Boot.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/ghcjs-boot/ghcjs-boot-tmp/Main.o )
/home/u/.stack/programs/x86_64-linux/ghcjs-0.2.1.9007019_ghc-8.0.1/src/src-bin/Boot.hs:690:1: warning: [-Wtabs]
Tab character found here, and in three further locations.
Please use spaces instead.
Linking .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/ghcjs-boot/ghcjs-boot ...
Preprocessing executable 'ghcjs-pkg' for ghcjs-0.2.1.9007019...
[1 of 1] Compiling Main ( src-bin/Pkg.hs, .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/ghcjs-pkg/ghcjs-pkg-tmp/Main.o )
Linking .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/ghcjs-pkg/ghcjs-pkg ...
/usr/bin/ld: cannot find -ltinfo
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
-- While building package ghcjs-0.2.1.9007019 using:
/home/u/.stack/programs/x86_64-linux/ghcjs-0.2.1.9007019_ghc-8.0.1/src/.stack-work/dist/x86_64-linux/Cabal-1.24.0.0/setup/setup --builddir=.stack-work/dist/x86_64-linux/Cabal-1.24.0.0 build lib:ghcjs exe:ghcjs exe:ghcjs-boot exe:ghcjs-pkg exe:ghcjs-run exe:haddock-ghcjs exe:hsc2hs-ghcjs --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
"Linking .stack-work/dist/x86_64-linux/Cabal-1.24.0.0/build/ghcjs-pkg/ghcjs-pkg ...
/usr/bin/ld: cannot find -ltinfo"
You are missing the libtinfo library which is part of ncurses. Depending on your environment try something like:
sudo apt-get install libtinfo-dev
As an aside, getting all the pieces that ghcjs needs to build successfully is tricky and not well documented as of September 2018. One might hope that as the project matures it will get easier to install, and that a binary package will be produced. Know that you are not the only person who has these issues. It takes some patience and trial-and-error to get ghcjs working right now.
Others have had success using nix, I did not.

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.

How can I fix wrong .cabal file of dependent package in Haskell Stack?

I use Haskell Stack in Windows 10
When I try to install gtk as dependency of my own package, I got following messages.
glib-0.13.2.2: configure
glib-0.13.2.2: build
Progress: 1/5
-- While building package glib-0.13.2.2 using:
C:\Users\junyoung\AppData\Local\Temp\stack6012\glib-0.13.2.2\.stack-work\dist\2672c1f3\setup\setup --builddir=.stack-work\dist\2672c1f3 build --ghc-options " -ddump-hi -ddump-to-file"
Process exited with code: ExitFailure 1
Logs have been written to: C:\Users\junyoung\Documents\HaskellProject\StackProject\Hotepad\.stack-work\logs\glib-0.13.2.2.log
[1 of 2] Compiling SetupWrapper ( SetupWrapper.hs, C:\Users\junyoung\AppData\Local\Temp\stack6012\glib-0.13.2.2\.stack-work\dist\2672c1f3\setup\SetupWrapper.o )
[2 of 2] Compiling Main ( C:\Users\junyoung\AppData\Local\Temp\stack6012\glib-0.13.2.2\Setup.hs, C:\Users\junyoung\AppData\Local\Temp\stack6012\glib-0.13.2.2\.stack-work\dist\2672c1f3\setup\Main.o )
Linking C:\Users\junyoung\AppData\Local\Temp\stack6012\glib-0.13.2.2\.stack-work\dist\2672c1f3\setup\setup.exe ...
[1 of 2] Compiling Gtk2HsSetup ( Gtk2HsSetup.hs, dist\setup-wrapper\Gtk2HsSetup.o )
[2 of 2] Compiling Main ( SetupMain.hs, dist\setup-wrapper\Main.o )
Linking dist/setup-wrapper\setup.exe ...
Configuring glib-0.13.2.2...
Building glib-0.13.2.2...
Preprocessing library glib-0.13.2.2...
.stack-work\dist\2672c1f3\build\System\Glib\StoreValue_hsc_utils.o:StoreValue_hsc_utils.c:(.text+0x0): multiple definition of `__debugbreak'
.stack-work\dist\2672c1f3\build\System\Glib\StoreValue_hsc_make.o:StoreValue_hsc_make.c:(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
linking .stack-work\dist\2672c1f3\build\System\Glib\StoreValue_hsc_make.o failed (exit code 1)
command was: C:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\mingw\bin\gcc.exe .stack-work\dist\2672c1f3\build\System\Glib\StoreValue_hsc_make.o .stack-work\dist\2672c1f3\build\System\Glib\StoreValue_hsc_utils.o -o .stack-work\dist\2672c1f3\build\System\Glib\StoreValue_hsc_make.exe -LC:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\lib -LC:/msys64/mingw64/lib -lgobject-2.0 -lglib-2.0 -lintl -LC:\Users\junyoung\AppData\Roaming\stack\snapshots\f21484d8\lib\x86_64-windows-ghc-7.10.3\utf8-string-1.0.1.1-L8eKHa7Iv9q7FVKUYW6u4b -LC:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\lib -LC:\Users\junyoung\AppData\Roaming\stack\snapshots\64a043b0\lib\x86_64-windows-ghc-7.10.3\text-1.2.2.1-HmqVQnZSpjaC156ABqPhne -LC:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\lib -LC:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\lib\binar_3uXFWMoAGBg0xKP9MHKRwi -LC:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\lib\conta_2C3ZI8RgPO2LBMidXKTvIU -LC:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\lib\bytes_6VWy06pWzJq9evDvK2d4w6 -LC:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\lib\deeps_6vMKxt5sPFR0XsbRWvvq59 -LC:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\lib\array_67iodizgJQIIxYVTp4emlA -LC:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\lib\base_HQfYBxpPvuw8OunzQu6JGM -lwsock32 -luser32 -lshell32 -LC:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\lib\integ_2aU3IZNMF9a7mQ0OzsZ0dS -LC:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\lib\ghcpr_8TmvWUcS1U1IKHT0levwg3 -LC:\Users\junyoung\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\lib/rts -lm -lwsock32 -lgdi32 -lwinmm
I found that this messages is because of glib.cabal files bug at glib-0.13.2.2, so when I try to install glib separately, I edit glib.cabal (remove -D___attribute__(A)= option on cpp) and install clearly.
However, when I try to install it using stack, stack install gtk command always takes Hackage one instead of installed glib package.
For short, therefore, my question is, how can I using separately installed glib? Or, is there any way to modify packages .cabal file while installing it, using options or whatever?
Stack lets you use a dependency from a local directory, or a github repo. So feel free to fork the project, do the fixes, maybe even do a PR, and then put this into your stack.yaml under "packages" section:
- location:
git: https://github.com/user/repo
commit: a1b3559090e9c75ce1d46969085fe4f918b2fa82

Resources