Gabriella439 / haskell-nix

Nix and Haskell in production
1.14k stars 116 forks source link

Setup.hs error with defaultUserHooks #87

Open xave opened 4 years ago

xave commented 4 years ago

I'm running through this tutorial and have received a Setup.hs variable not in scope error.

My setup:

- macOS
- nix 2.3.4 (default everything)
- cabal-install 3.2.0.0
- ghc 8.8.3

I am on "project1" tutorial. First of all, as expected a few more package dependencies are in need of updates, but those are easily fixed using the techniques laid out in project1. In particular, the packages that need to be updated as of today are transformers-compat (updated to v.0.3) and process (updated to 1.0.0.0). I mention these for completeness.

After getting those two to resolve, the following error shows up:

unpacking source archive /nix/store/pqi02g9sfgpyy34q4kask6ji33rd5smp-process-1.0.0.0.tar.gz
source root is process-1.0.0.0
setting SOURCE_DATE_EPOCH to timestamp 1194101034 of file process-1.0.0.0/process.cabal
patching sources
Replace Cabal file with edited version from mirror://hackage/process-1.0.0.0/revision/1.cabal.
compileBuildDriverPhase
setupCompileFlags: -package-db=/private/var/folders/mf/0dt_gdys2y5238lgxttwqmcw0000gn/T/nix-build-process-1.0.0.0.drv-0/setup-package.conf.d -j8 -threaded -rtsopts
[1 of 1] Compiling Main             ( Setup.hs, /private/var/folders/mf/0dt_gdys2y5238lgxttwqmcw0000gn/T/nix-build-process-1.0.0.0.drv-0/Main.o )

Setup.hs:6:29: error:
    Variable not in scope: defaultUserHooks :: UserHooks
  |
6 | main = defaultMainWithHooks defaultUserHooks
  |                             ^^^^^^^^^^^^^^^^

builder for '/nix/store/lw2z25y6ydgv521gb0yirw7dgff1ji8c-process-1.0.0.0.drv' failed with exit code 1
cannot build derivation '/nix/store/n5whsryy0kvadhflzzm86yv3vldj6aa8-turtle-1.3.2.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/2lzl5qhaagsq7p0y6gp8mh10n6nmylq6-project1-1.0.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/2lzl5qhaagsq7p0y6gp8mh10n6nmylq6-project1-1.0.0.drv' failed

with this snippet bolded

Setup.hs:6:29: error: Variable not in scope: defaultUserHooks :: UserHooks | 6 | main = defaultMainWithHooks defaultUserHooks |_____^^^^^^^^^^^^^^^^


Called with this command:

nix-build -v --attr project1 release3.nix

Any ideas?

xave commented 4 years ago

Below is an excerpt of dump with max verbosity turned on. Over 9000 lines long otherwise.


building of '/nix/store/lw2z25y6ydgv521gb0yirw7dgff1ji8c-process-1.0.0.0.drv': all inputs realised
building path '/nix/store/d50rva0qs16ib7vdvkr9aanbw2pz57zw-process-1.0.0.0-doc'
building path '/nix/store/kl7f2l40bghb962lz154zx5a1wyjrz0h-process-1.0.0.0'

added input paths '/nix/store/04z6bfbdrj784cg6mw7mp85zjp26fasa-zlib-1.2.11', 
'/nix/store/0878vc6mh11sym9f3s8r9765czz0jbc2-gmp-6.2.0-dev', 
'/nix/store/0wkd82rzvnsxi9v1akgdmkpv40fb160x-bzip2-1.0.6.0.1-bin', 
'/nix/store/2l4i1z8aphpv549ghcfsz0cghvz0m4s0-gawk-5.1.0', 
'/nix/store/35cd58md7kbsac90gzslk6n8l6k9hg1f-xz-5.2.5', 
'/nix/store/3fhvw4s3ny88jf168ig7qsi887q7yigf-llvm-7.1.0-lib', 

'/nix/store/4mdp8nhyfddh7bllbi7xszz7k9955n79-Setup.hs',

...

building of '/nix/store/wnyq2lxk6lig7xq16aid9m2z0gpwnvin-transformers-compat-0.3.drv': all inputs realised
building path '/nix/store/qn5w3wrx3a09lc7zxj90mhav9746f6jb-transformers-compat-0.3'

added input paths '/nix/store/04z6bfbdrj784cg6mw7mp85zjp26fasa-zlib-1.2.11', 
'/nix/store/0878vc6mh11sym9f3s8r9765czz0jbc2-gmp-6.2.0-dev', 
'/nix/store/0wkd82rzvnsxi9v1akgdmkpv40fb160x-bzip2-1.0.6.0.1-bin', 
'/nix/store/2l4i1z8aphpv549ghcfsz0cghvz0m4s0-gawk-5.1.0', 
'/nix/store/35cd58md7kbsac90gzslk6n8l6k9hg1f-xz-5.2.5', 
'/nix/store/3fhvw4s3ny88jf168ig7qsi887q7yigf-llvm-7.1.0-lib', 

'/nix/store/4mdp8nhyfddh7bllbi7xszz7k9955n79-Setup.hs',

...

patching sources
Replace Cabal file with edited version from mirror://hackage/process-1.0.0.0/revision/1.cabal.
compileBuildDriverPhase
setupCompileFlags: -package-db=/private/var/folders/mf/0dt_gdys2y5238lgxttwqmcw0000gn/T/nix-build-process-1.0.0.0.drv-0/setup-package.conf.d -j8 -threaded -rtsopts
[1 of 1] Compiling Main             ( Setup.hs, /private/var/folders/mf/0dt_gdys2y5238lgxttwqmcw0000gn/T/nix-build-process-1.0.0.0.drv-0/Main.o )

Setup.hs:6:29: error:
    Variable not in scope: defaultUserHooks :: UserHooks
  |
6 | main = defaultMainWithHooks defaultUserHooks
  |                             ^^^^^^^^^^^^^^^^
building of '/nix/store/lw2z25y6ydgv521gb0yirw7dgff1ji8c-process-1.0.0.0.drv': got EOF

building of '/nix/store/lw2z25y6ydgv521gb0yirw7dgff1ji8c-process-1.0.0.0.drv': woken up
building of '/nix/store/lw2z25y6ydgv521gb0yirw7dgff1ji8c-process-1.0.0.0.drv': build done

These are all the times Setup.hs appears in the output. Notice that they are with regards to the two packages I updated (process and transformers-compat) via cabal2nix using the strategy from project1 tutorial. Also note that without updating those two packages, the derivation won't build at all, stating that the two process and transformers-compat are not in a compatible version range. So it seems that changing them and leaving them alone both cause issues.

xave commented 4 years ago

So far in my explorations of nix and Haskell, I have encountered two common issues with building Haskell projects. The first is the packages not being in the right range, which seems to be resolved by the strategy of using cabal2nix to make a nix file for the specific version and adding it to the release.nix file as shown in the tutorial. The second issue I keep running into even with other tutorials is this Setup.hs issue. It's consistently these two.

Gabriella439 commented 4 years ago

@xave: The defaultUserHooks issue is something that I've never run into, but I can guess at what might be causing that problem. defaultUserHooks is a deprecated utility from the Cabal Haskell package that was removed in Cabal-3.0.0.0, so my guess is that you're running into this issue because you're building an older Haskell package with a newer version of Cabal and upgrading the package to a newer Cabal-3.0.0.0-compatible version will resolve the error.

xave commented 4 years ago

@Gabriel439 Thank you. I will look into this and get back.