Stack: Installation of ghc-8.2.2 via stack setup fails on Mac OS X

Created on 3 Jan 2018  路  18Comments  路  Source: commercialhaskell/stack

The installation of ghc-8.2.2 via stack fails on Mac OS X:

$ stack setup --verbose
Version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b060000db (5454 commits) x86_64 hpack-0.20.0
2018-01-03 08:19:22.978526: [debug] Checking for project config at: /Users/testuser/stack.yaml
@(Stack/Config.hs:842:9)
2018-01-03 08:19:22.979252: [debug] Checking for project config at: /Users/stack.yaml
@(Stack/Config.hs:842:9)
2018-01-03 08:19:22.979345: [debug] Checking for project config at: /stack.yaml
@(Stack/Config.hs:842:9)
2018-01-03 08:19:22.979442: [debug] No project config file found, using defaults.
@(Stack/Config.hs:872:13)
2018-01-03 08:19:22.980485: [debug] Run from outside a project, using implicit global project config
@(Stack/Config.hs:559:13)
2018-01-03 08:19:22.980826: [debug] Using resolver: lts-10.2 from implicit global project's config file: /Users/testuser/.stack/global-project/stack.yaml
@(Stack/Config.hs:573:32)
2018-01-03 08:19:22.980944: [debug] Decoding build plan from: /Users/testuser/.stack/build-plan/lts-10.2.yaml
@(Stack/Snapshot.hs:150:5)
2018-01-03 08:19:22.981031: [debug] Trying to decode /Users/testuser/.stack/build-plan-cache/lts-10.2.cache
@(Data/Store/VersionTagged.hs:66:5)
2018-01-03 08:19:22.986519: [debug] Success decoding /Users/testuser/.stack/build-plan-cache/lts-10.2.cache
@(Data/Store/VersionTagged.hs:70:13)
2018-01-03 08:19:22.986799: [debug] Using standard GHC build
@(Stack/Setup.hs:617:9)
2018-01-03 08:19:23.238907: [info] Preparing to install GHC to an isolated location.
@(Stack/Setup.hs:877:5)
2018-01-03 08:19:23.239215: [info] This will not interfere with any system-level installation.
@(Stack/Setup.hs:886:5)
2018-01-03 08:19:23.239684: [debug] Downloading from https://github.com/commercialhaskell/ghc/releases/download/ghc-8.2.2-release/ghc-8.2.2-x86_64-apple-darwin.tar.bz2 to /Users/testuser/.stack/programs/x86_64-osx/ghc-8.2.2.tar.bz2 ...
@(Stack/Setup.hs:1460:5)
2018-01-03 08:19:23.239783: [debug] Will check against sha1 hash: 2449769c9e2791f65d666b7063778f0b22dea665
@(Stack/Setup.hs:1474:13)
2018-01-03 08:19:23.239873: [debug] Will check against sha256 hash: 7968bb7fbf454cdef47a36cb26621c8b9d42576e280500a5484778312d56b98d
@(Stack/Setup.hs:1474:13)
Already downloaded.                
2018-01-03 08:19:24.854511: [debug] menv = fromList [("HOME","/Users/testuser"),("LANG","en_US.UTF-8"),("LC_CTYPE",""),("LESS","-R"),("LOGNAME","testuser"),("LSCOLORS","Gxfxcxdxbxegedabagacad"),("MAIL","/var/mail/testuser"),("OLDPWD","/Users/testuser"),("PAGER","less"),("PATH","/Users/testuser/google-cloud-sdk/bin:/Users/testuser/.local/bin:/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Developer/NVIDIA/CUDA-8.0/bin"),("PWD","/Users/testuser"),("SHELL","/bin/zsh"),("SHLVL","1"),("SSH_CLIENT","192.168.0.13 56820 22"),("SSH_CONNECTION","192.168.0.13 56820 192.168.0.10 22"),("SSH_TTY","/dev/ttys000"),("TERM","xterm-256color"),("TMPDIR","/var/folders/bz/jwspshwj2lv3j6ggtf49ww_h0000gn/T/"),("USER","testuser"),("ZSH","/Users/testuser/.oh-my-zsh"),("_","/usr/local/bin/stack"),("__CF_USER_TEXT_ENCODING","0x1F5:0x0:0x0")]
@(Stack/Setup.hs:1010:5)
2018-01-03 08:19:24.855188: [debug] ziptool: bzip2
@(Stack/Setup.hs:1028:5)
2018-01-03 08:19:24.855265: [debug] make: gmake
@(Stack/Setup.hs:1029:5)
2018-01-03 08:19:24.855329: [debug] tar: tar
@(Stack/Setup.hs:1030:5)
2018-01-03 08:19:24.855447: [debug] Unpacking /Users/testuser/.stack/programs/x86_64-osx/ghc-8.2.2.tar.bz2
@(Stack/Setup.hs:1057:5)
2018-01-03 08:19:24.855736: [debug] Run process: /usr/bin/tar jxf /Users/testuser/.stack/programs/x86_64-osx/ghc-8.2.2.tar.bz2
@(System/Process/Log.hs:37:3)
2018-01-03 08:19:59.855599: [debug] Process finished in 34997ms: /usr/bin/tar jxf /Users/testuser/.stack/programs/x86_64-osx/ghc-8.2.2.tar.bz2
@(System/Process/Log.hs:44:3)
2018-01-03 08:19:59.856030: [debug] Run process: /Users/testuser/.stack/programs/x86_64-osx/ghc-8.2.2.temp/ghc-8.2.2/configure --prefix=/Users/testuser/.stack/programs/x86_64-osx/ghc-8.2.2/
@(System/Process/Log.hs:37:3)
2018-01-03 08:20:03.555714: [debug] Process finished in 3699ms: /Users/testuser/.stack/programs/x86_64-osx/ghc-8.2.2.temp/ghc-8.2.2/configure --prefix=/Users/testuser/.stack/programs/x86_64-osx/ghc-8.2.2/
@(System/Process/Log.hs:44:3)
2018-01-03 08:20:03.556078: [debug] Run process: /usr/local/bin/gmake install
@(System/Process/Log.hs:37:3)
2018-01-03 08:20:03.560699: [error] Running /usr/local/bin/gmake install in directory /Users/testuser/.stack/programs/x86_64-osx/ghc-8.2.2.temp/ghc-8.2.2/ exited with ExitFailure 2


mk/config.mk:533: *** missing separator.  Stop.

@(Stack/Setup.hs:1043:21)
2018-01-03 08:20:03.560854: [error] 
Error: Error encountered while installing GHC with
         gmake install
         run in /Users/testuser/.stack/programs/x86_64-osx/ghc-8.2.2.temp/ghc-8.2.2/

       The following directories may now contain files, but won't be used by stack:
         - /Users/testuser/.stack/programs/x86_64-osx/ghc-8.2.2.temp/
         - /Users/testuser/.stack/programs/x86_64-osx/ghc-8.2.2/

@(Stack/PrettyPrint.hs:63:22)
Installing GHC ...% 

Lines 528ff of .stack/programs/x86_64-osx/ghc-8.2.2.temp/ghc-8.2.2/mk/config.mk are:

# NB. Don't override $(CC) using build.mk,  re-configure using
# the flag CC=<blah> instead.  The reason is that the configure script
# needs to know which gcc you're using in order to perform its tests.

GccVersion            = 9.0.0
8.0
ifeq "$(phase)" "0"
CrossCompilePrefix    =
else
CrossCompilePrefix    = 

Clearly, an erroneous 8.0 slipped in (line 533). (And not surprisingly, ghc compiles fine after the line was deleted.)

This looks a bit like a faulty sed operation. Or maybe we have a MAC sed vs. gsed issue?

All is well when I download ghc-8.2.2 from https://www.haskell.org/ or https://github.com/commercialhaskell and do the usual ./configure && make, so it's doesn't look like it's a ghc issue.

Infos

The Stack version is

$ stack --version
Version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b060000db (5454 commits) x86_64 hpack-0.20.0

stack was installed like so:

wget -qO- https://get.haskellstack.org/ | sh

os x / macos further investigation required bug

Most helpful comment

Same issue on 8.4.4 :(

All 18 comments

I think this is a ghc issue, not a stack issue.

Possibly, not sure. What do think @borsboom ?

I'm a macOS user and haven't had any trouble with stack setup installing GHC 8.2.2 locally (I just retried with stack setup --reinstall). I also tried unpacking the stack-downloaded ~/.stack/programs/x86_64-osx/ghc-8.2.2.tar.bz2 myself and running ./configure --prefix=/tmp/ghc-8.2.2, and the generated mk/config.mk doesn't have the extra 8.0. What happens if you do the same exercise? Also, which version of macOS are you running? (I'm on 10.12.6 Sierra).

We repack the GHC 8.2.2 bindist from https://downloads.haskell.org/~ghc/8.2.2/ with bz2 (since macOS doesn't have xz installed by default), but otherwise leave it unchanged from the official bindist. Unfortunately the repack means we can't directly compare the SHA1 sum with the official bindist.

I run macOS version 10.13.2 and have almost exactly the same issue as @mcmayer. I just tested stack setup --reinstall with the same result.

I also have Version 1.6.3

> stack --version
Version 1.6.3, Git revision b27e629b8c4ce369e3b8273f04db193b060000db (5454 commits) x86_64 hpack-0.20.0

However, instead of an 8.0 strangely a 7.0 has been included in line 533.

GccVersion            = 9.0.0
7.0

Now, if I unpack as @borsboom suggested the stack-downloaded ~/.stack/programs/x86_64-osx/ghc-8.2.2.tar.bz2 myself and run ./configure --prefix=/tmp/ghc-8.2.2, then the generated mk/config.mk does have the extra 7.0. I used /opt/local/bin/bunzip2 (MacPorts) and /usr/bin/tar to extract the files.

I am not an expert on stack at all, but does it have to do with High Sierra? Or does my MacPorts installation interfere?

Is it possible that you've somehow ended up with multiple GCC versions on your system (maybe via MacPorts)? Since you're seeing the same behaviour when you manually configure GHC, it looks like GHC's configure has a bug, which would make this an upstream issue.

Can you also try downloading an original GHC bindist from https://www.haskell.org/ghc/download_ghc_8_2_2.html#macosx_x86_64 and confirm that it still happens with that?

Situation update: I run OS 10.13 as well and I use mac 'brew'.
However, after leaving it for a few days and doing some other stuff the problem suddenly disappeared. I don't see what I did that could possibly affect ghc, except for the regular 'brew update && brew upgrade's and I don't recall any OS X software updates. Weird.

Yes, @borsboom,

I also get the same problem when I extract from the binary distribution.
However, I also tried to install the previous version as binary distribution (ghc-8.2.1), which I had installed earlier without problems. And now it fails!

Thus there seem to be problems with the installation of ghc on High Sierra (at least with my configuration). So it seems not to be a stack issue! Strange that it works for @mcmayer now.

I suspect a problem with MacPorts, but after renaming the MacPorts directory, I have the same problems. Very strange...

Situation update 2: Actually, the software update "Command line tools (macOS High Sierra version 10.13) for XCode" ran. That definitely changed something that could well affect the configure/autotools business for GHC.

When I run configure, the output shows:

checking version of gcc... 9.1.0
8.0

and later:

configure: WARNING: cache variable fp_cv_gcc_version contains a newline

So it looks like it's calculating the gcc version incorrectly with the following:

gcc -v 2>&1 | grep 'version ' | sed -e 's/.*version [^0-9]*\([0-9.]*\).*/\1/g'

The output of gcc -v is:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin17.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Found CUDA installation: /usr/local/cuda, version 8.0

So, I think the confounding line is the last line, from CUDA.

I don't know enough about the expected output of gcc version, but I tried changing gcc -v to gcc --version and the CUDA line went away. --version is undocumented in gcc --help though -v is documented as Show commands to run and use verbose output which doesn't imply version...

So one way to fix this is to change to --version, but I don't know what that does to other GCC or other platforms. Another is to work around CUDA by adding a | grep -v "CUDA", but that assumes CUDA is the only thing that adds an output containing the string version.

There is also gcc -dumpversion which outputs 4.2.1.
See: https://stackoverflow.com/questions/5188267/checking-the-gcc-version-in-a-makefile

Looks like this was fixed in 8.4.1: https://ghc.haskell.org/trac/ghc/ticket/14724

Same issue on 8.4.4 :(

Same issue on 8.6.3, still not fixed

It also appears that gcc -v has been changed to --version in the latest releases, as the poster above suggested, but that still does not resolve the issue.

I have the same problem, but it also fails with stack setup --reinstall.
I am running stack Version 1.9.3 on MacOS High Sierra Mojave, vs. 10.14.4 (18E226).
This is what I got:

BA92-C02VP224HTDF:Ampersand stefjoosten$ stack setup --reinstall
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Already downloaded.                
Installing GHC ...                                                                  
Received ExitFailure 2 when running
Raw command: /usr/bin/make install
Run from: /Users/stefjoosten/.stack/programs/x86_64-osx/ghc-8.6.2.temp/ghc-8.6.2/

BA92-C02VP224HTDF:Ampersand stefjoosten$ 

@stefjoosten take a look at this issue, I had the same issue and it have been solved after installing gmp

Was stuck on this problem for ~2 hours using lts-10.0, and changing my resolver to lts-13.26 (ghc-8.6.5) solved the problem.

On macOS Mojave 10.14.5 and

$ stack setup --reinstall

fixed everything for me!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

igrep picture igrep  路  3Comments

mgsloan picture mgsloan  路  3Comments

symbiont-joseph-kachmar picture symbiont-joseph-kachmar  路  3Comments

abhinav picture abhinav  路  4Comments

bitemyapp picture bitemyapp  路  3Comments