commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.98k stars 842 forks source link

stack fails #5059

Closed s5k6 closed 4 years ago

s5k6 commented 4 years ago

General summary/comments (optional)

I've tried to follow the Quick Start Guide, but it fails.

The only deviation is that I insist to use the GHC (version 8.6.5) installed on the system. I cannot check without, because the download would take approx. 6h.

Steps to reproduce

$ rm -rf ~/.stack ~/.ghc ~/.cabal

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5

$ stack --version
Version 2.1.3, Git revision b2e2f3d0568e6d73fc0477dee8ca7c04466ec1f6 (dirty) (7736 commits) x86_64
Compiled with:
- Cabal-2.4.0.1
- Glob-0.10.0
- StateVar-1.1.1.1
- aeson-1.4.4.0
- annotated-wl-pprint-0.7.0
- ansi-terminal-0.9.1
- ansi-wl-pprint-0.6.9
- array-0.5.3.0
- asn1-encoding-0.9.5
- asn1-parse-0.9.4
- asn1-types-0.3.3
- async-2.2.2
- attoparsec-0.13.2.3
- attoparsec-iso8601-1.0.1.0
- auto-update-0.1.6
- base-4.12.0.0
- base-compat-0.10.5
- base-orphans-0.8.1
- base-prelude-1.3
- base16-bytestring-0.1.1.6
- base64-bytestring-1.0.0.2
- basement-0.0.11
- bifunctors-5.5.5
- binary-0.8.6.0
- bitarray-0.0.1.1
- blaze-builder-0.4.1.0
- blaze-html-0.9.1.2
- blaze-markup-0.8.2.2
- bytestring-0.10.8.2
- case-insensitive-1.2.1.0
- cereal-0.5.8.1
- clock-0.8
- colour-2.3.5
- comonad-5.0.5
- conduit-1.3.1.1
- conduit-extra-1.3.4
- connection-0.3.0
- constraints-0.11
- containers-0.6.0.1
- contravariant-1.5.2
- cookie-0.4.4
- cryptohash-sha256-0.11.101.0
- cryptonite-0.26
- cryptonite-conduit-0.2.2
- data-default-class-0.1.2.0
- deepseq-1.4.4.0
- digest-0.0.1.2
- directory-1.3.3.0
- distributive-0.6.1
- dlist-0.8.0.7
- easy-file-0.2.2
- echo-0.1.3
- ed25519-0.0.5.0
- either-5.0.1.1
- enclosed-exceptions-1.0.3
- exceptions-0.10.3
- extra-1.6.18
- fast-logger-2.4.17
- file-embed-0.0.11
- filelock-0.1.1.3
- filepath-1.4.2.1
- fsnotify-0.3.0.1
- generic-deriving-1.12.4
- ghc-boot-th-8.6.5
- ghc-prim-0.5.3
- githash-0.1.3.2
- hackage-security-0.5.3.0
- hashable-1.2.7.0
- hi-file-parser-0.1.0.0
- hinotify-0.4
- hourglass-0.2.12
- hpack-0.33.0
- hpc-0.6.0.3
- http-api-data-0.4.1
- http-client-0.6.4
- http-client-tls-0.3.5.3
- http-conduit-2.3.7.2
- http-download-0.1.0.0
- http-types-0.12.3
- infer-license-0.2.0
- integer-gmp-1.0.2.0
- integer-logarithms-1.0.3
- libyaml-0.1.1.0
- lifted-async-0.10.0.4
- lifted-base-0.2.3.12
- megaparsec-7.0.5
- memory-0.14.18
- microlens-0.4.11.2
- microlens-th-0.4.3.2
- mime-types-0.1.0.9
- mintty-0.1.2
- monad-control-1.0.2.3
- monad-logger-0.3.30
- monad-loops-0.4.3
- mono-traversable-1.0.13.0
- mtl-2.2.2
- mustache-2.3.0
- neat-interpolation-0.3.2.4
- network-2.8.0.0
- network-uri-2.6.1.0
- old-locale-1.0.0.7
- old-time-1.1.0.3
- open-browser-0.2.1.0
- optparse-applicative-0.14.3.0
- optparse-simple-0.1.1.2
- pantry-0.1.1.1
- parsec-3.1.13.0
- parser-combinators-1.2.0
- path-0.6.1
- path-io-1.4.2
- path-pieces-0.2.1
- pem-0.2.4
- persistent-2.10.1
- persistent-sqlite-2.10.5
- persistent-template-2.7.2
- pretty-1.1.3.6
- primitive-0.6.4.0
- process-1.6.5.0
- profunctors-5.5
- project-template-0.2.0.1
- random-1.1
- regex-applicative-0.3.3.1
- regex-applicative-text-0.1.0.1
- resource-pool-0.2.3.2
- resourcet-1.2.2
- retry-0.8.1.0
- rio-0.1.12.0
- rio-orphans-0.1.1.0
- rio-prettyprint-0.1.0.0
- rts-1.0
- safe-0.3.17
- safe-exceptions-0.1.7.0
- scientific-0.3.6.2
- semigroupoids-5.3.3
- shelly-1.8.1
- silently-1.2.5.1
- socks-0.6.1
- split-0.2.3.3
- stm-2.5.0.0
- stm-chans-3.0.0.4
- streaming-commons-0.2.1.1
- syb-0.7.1
- system-fileio-0.3.16.4
- system-filepath-0.4.14
- tagged-0.8.6
- tar-0.5.1.1
- tar-conduit-0.3.2
- template-haskell-2.14.0.0
- temporary-1.3
- terminal-size-0.3.2.1
- text-1.2.3.1
- text-metrics-0.3.0
- th-abstraction-0.3.1.0
- th-expand-syns-0.4.5.0
- th-lift-0.8.0.1
- th-lift-instances-0.1.14
- th-orphans-0.13.7
- th-reify-many-0.1.9
- th-utilities-0.2.3.0
- time-1.8.0.2
- time-compat-1.9.2.2
- tls-1.4.1
- transformers-0.5.6.2
- transformers-base-0.4.5.2
- transformers-compat-0.6.5
- typed-process-0.2.6.0
- unicode-transforms-0.3.6
- unix-2.7.2.2
- unix-compat-0.5.2
- unix-time-0.4.7
- unliftio-0.2.12
- unliftio-core-0.1.2.0
- unordered-containers-0.2.10.0
- uuid-types-1.0.3
- vector-0.12.0.3
- vector-algorithms-0.8.0.1
- x509-1.7.5
- x509-store-1.6.7
- x509-system-1.6.6
- x509-validation-1.6.11
- yaml-0.11.1.2
- zip-archive-0.4.1
- zlib-0.6.2.1

Warning: this is an unsupported build that may use different versions of
dependencies and GHC than the officially released binaries, and therefore may
not behave identically.  If you encounter problems, please try the latest
official build by running 'stack upgrade --force-download'.

Yes, I've tried this suggestion, to no avail.

$ stack config set system-ghc --global true
/home/sk/.stack/config.yaml has been updated.

$ stack new whatever
Downloading template "new-template" to create project "whatever" in whatever/ ...

The following parameters were needed by the template but not provided: author-name
You can provide them in /home/sk/.stack/config.yaml, like this:
templates:
  params:
    author-name: value
Or you can pass each one as parameters like this:
stack new whatever new-template -p "author-name:value"

The following parameters were needed by the template but not provided: author-email, author-name, category, copyright, github-username
You can provide them in /home/sk/.stack/config.yaml, like this:
templates:
  params:
    author-email: value
    author-name: value
    category: value
    copyright: value
    github-username: value
Or you can pass each one as parameters like this:
stack new whatever new-template -p "author-email:value" -p "author-name:value" -p "category:value" -p "copyright:value" -p "github-username:value"

Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- whatever/

Selecting the best among 16 snapshots...

* Matches lts-14.11

Selected resolver: lts-14.11
Initialising configuration using resolver: lts-14.11
Total number of user packages considered: 1
Writing configuration to file: whatever/stack.yaml
All done.

$ cd whatever/

$ stack setup
stack will use the GHC on your PATH
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec

$ stack build
[1 of 2] Compiling Main             ( /home/sk/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /home/sk/.stack/setup-exe-src/setup-mPHDZzAJ.o )

/home/sk/.stack/setup-exe-src/setup-mPHDZzAJ.hs:1:1: error:
    Could not find module ‘Prelude’
    There are files missing in the ‘base-4.12.0.0’ package,
    try running 'ghc-pkg check'.
    Use -v to see a list of the files searched for.
  |
1 | import Distribution.Simple
  | ^

/home/sk/.stack/setup-exe-src/setup-mPHDZzAJ.hs:1:1: error:
    Could not find module ‘Distribution.Simple’
    There are files missing in the ‘Cabal-2.4.0.1’ package,
    try running 'ghc-pkg check'.
    Use -v to see a list of the files searched for.
  |
1 | import Distribution.Simple
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

--  While building simple Setup.hs using:
      /usr/bin/ghc-8.6.5 -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-2.4.0.1 /home/sk/.stack/setup-exe-src/setup-mPHDZzAJ.hs /home/sk/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /home/sk/.stack/setup-exe-cache/x86_64-linux/tmp-Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5
    Process exited with code: ExitFailure 1

Expected

Expected to see successful compilation

Actual

Compilation failed

Method of installation

Packages from ArchLinux official repositories

https://www.archlinux.org/packages/
mattaudesse commented 4 years ago

Hi @s5k6,

Have you tried running ghc-pkg -v0 check?

s5k6 commented 4 years ago

Yes, ghc-pkg -v0 check prints 510 error messages, the first of which are below. They all start with Warning: haddock-.

$ ghc-pkg -v0 check 2>&1 |head
Warning: haddock-interfaces: /usr/share/doc/stack/html/stack.haddock doesn't exist or isn't a file
Warning: haddock-html: /usr/share/doc/stack/html doesn't exist or isn't a directory
Warning: haddock-interfaces: /usr/share/doc/pandoc/html/pandoc.haddock doesn't exist or isn't a file
Warning: haddock-html: /usr/share/doc/pandoc/html doesn't exist or isn't a directory
Warning: haddock-interfaces: /usr/share/doc/haskell-pantry/html/pantry.haddock doesn't exist or isn't a file
Warning: haddock-html: /usr/share/doc/haskell-pantry/html doesn't exist or isn't a directory
Warning: haddock-interfaces: /usr/share/doc/haskell-mustache/html/mustache.haddock doesn't exist or isn't a file
Warning: haddock-html: /usr/share/doc/haskell-mustache/html doesn't exist or isn't a directory
Warning: haddock-interfaces: /usr/share/doc/haskell-http/html/HTTP.haddock doesn't exist or isn't a file
Warning: haddock-html: /usr/share/doc/haskell-http/html doesn't exist or isn't a directory

But I have found something else →next message

s5k6 commented 4 years ago

There seems to be a similar problem with cabal

$ cabal --version
cabal-install version 2.4.0.0
compiled using version 2.4.0.1 of the Cabal library 
$ mkdir sfklshfsdf
$ cd sfklshfsdf
$ cabal init
[... answer manyquestions ...]
$ cabal v2-build
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
 - sfklshfsdf-0.1.0.0 (exe:sfklshfsdf) (first run)
Configuring executable 'sfklshfsdf' for sfklshfsdf-0.1.0.0..
Preprocessing executable 'sfklshfsdf' for sfklshfsdf-0.1.0.0..
Building executable 'sfklshfsdf' for sfklshfsdf-0.1.0.0..
[1 of 1] Compiling Main             ( Main.hs, /tmp/sfklshfsdf/dist-newstyle/build/x86_64-linux/ghc-8.6.5/sfklshfsdf-0.1.0.0/x/sfklshfsdf/build/sfklshfsdf/sfklshfsdf-tmp/Main.o )

Main.hs:1:8: error:
    Could not find module ‘Prelude’
    There are files missing in the ‘base-4.12.0.0’ package,
    try running 'ghc-pkg check'.
    Use -v to see a list of the files searched for.
  |
1 | module Main where
  |        ^^^^

According to this stackoverflow question, the culprit is GHC (not) expecting shared libraries.

For cabal, adding

ghc-options: -dynamic

to the executable section in the the .cabal file solved the problem.

This solution, however, does not solve the problem for stack, i.e., I've appended -dynamic to all ghc-options I could find in the stack-generated .cabal-file, but the error persists.

mattaudesse commented 4 years ago

I think you'll want to pass ghc options via stack.yaml as described here instead. Are you able to make it work that way?

s5k6 commented 4 years ago

Hmm, after removing all comments from stack.yaml, and adding the last two lines, it reads:

resolver: lts-14.11
packages:
- .

ghc-options:
    "$locals": -dynamic

but the error seems to be the same:

$ stack build
[1 of 2] Compiling Main             ( /home/sk/.stack/setup-exe-src/setup-mPHDZzAJ.hs, /home/sk/.stack/setup-exe-src/setup-mPHDZzAJ.o )

/home/sk/.stack/setup-exe-src/setup-mPHDZzAJ.hs:1:1: error:
    Could not find module ‘Prelude’
    There are files missing in the ‘base-4.12.0.0’ package,
    try running 'ghc-pkg check'.
    Use -v to see a list of the files searched for.
  |
1 | import Distribution.Simple
  | ^

/home/sk/.stack/setup-exe-src/setup-mPHDZzAJ.hs:1:1: error:
    Could not find module ‘Distribution.Simple’
    There are files missing in the ‘Cabal-2.4.0.1’ package,
    try running 'ghc-pkg check'.
    Use -v to see a list of the files searched for.
  |
1 | import Distribution.Simple
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

--  While building simple Setup.hs using:
      /usr/bin/ghc-8.6.5 -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is StackSetupShim.mainOverride -package Cabal-2.4.0.1 /home/sk/.stack/setup-exe-src/setup-mPHDZzAJ.hs /home/sk/.stack/setup-exe-src/setup-shim-mPHDZzAJ.hs -o /home/sk/.stack/setup-exe-cache/x86_64-linux/tmp-Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5
    Process exited with code: ExitFailure 1

I've noticed, that -dynamic does not show up in the line showing how the compiler is being called...

mattaudesse commented 4 years ago

I'm kind of flying blind here since I don't have a setup that'll allow me to reproduce, but I wonder if swapping $locals with $everything would cause it to work?

In any case, we might have better luck consulting Arch's forums/wiki/etc since this problem seems to be more related to their package management strategy than stack itself.

Based on the stack overflow link you pasted above there also appears to be an alternative ghc-static package you could try installing - have you tried (+had any luck with) that instead?

s5k6 commented 4 years ago

About using $everything: Same result.

I've just tested with additionally hinstalling the ghc-static package (allegedly allocating another 1260.62 MiB), and it works.

Interestingly, with ghc-options: "$locals": -dynamic, this builds an executable of 18kB, and without this option it builds an executable of 1.1M in size.

Also, after deinstalling ghc-static, compilation succeeds with the -dynamic flag present in stack.yaml, and fails without (complains about missing Lib in base-4.12.0.0).

Maybe you're right, and it's a packaging thing. I'll try to drop the packager a note, linking to this issue.

For now, thanks for your help, but please don't waste your time on this, I'll stick with plain cabal for the time being.

Please excuse this rant: I have to say that I find the state of Haskells compiler infrastructure the most appalling aspect of it all. I have used and taught Haskell for over a decade, albeit in a rather researchy way, or for pet projects, i.e., neither industrial nor commercial applications. This time is over (since 2016), but occasionally I come back with an idea I wonder what it would be like to do it in Haskell. And then I need a library, and hit the wall of cabal or stack. And I have not seen this situation improve much in recent years. I find this sad, because Haskell is such a nice language. As said above: I'll try cabal with its “new style” stuff, and see how it goes. Wish me luck!