Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stack build failing with new project on MacOS #4399

Closed
dpkatz opened this issue Nov 15, 2018 · 19 comments
Closed

stack build failing with new project on MacOS #4399

dpkatz opened this issue Nov 15, 2018 · 19 comments

Comments

@dpkatz
Copy link

dpkatz commented Nov 15, 2018

General summary/comments (optional)

When I create a new project and try to build it without changing anything, it fails. If I just run ghc by hand, it succeeds so I don't think it's a GHC issue. Could it be an incompatibility between stack and the MacOS command line tools? I just noticed this a few days ago, and there had been an update to the MacOS command line tools in the meantime...

A few things I've tried:

  • I removed ghc and binutils from homebrew (no change)
  • I was seeing this with the homebrew stack-1.7.1, so I switched to stack-1.9.1 via the usual curl -sSL https://get.haskellstack.org/ | sh (no change)

I'd appreciate any suggestions!

Steps to reproduce

  1. stack new buildtest
  2. cd buildtest
  3. stack setup
  4. stack build

Expected

I expect the virgin project to build cleanly.

Actual

$ stack build
Building all executables for `footest' once. After a successful build of all of them, only specified executables will be rebuilt.
footest-0.1.0.0: build (lib + exe)
Preprocessing library for footest-0.1.0.0..
Building library for footest-0.1.0.0..
ar: @.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/objs-9861/ar9861-0.rsp: No such file or directory

--  While building package footest-0.1.0.0 using:
      /Users/dkatz/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.2.0.1 build lib:footest exe:footest-exe --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

Here's the output of verbose mode:

$ stack build --verbose
Version 1.9.1, Git revision f9d0042c141660e1d38f797e1d426be4a99b2a3c (6168 commits) x86_64 hpack-0.31.0
2018-11-14 21:08:50.604852: [debug] Checking for project config at: /Users/dkatz/junk/footest/stack.yaml
2018-11-14 21:08:50.605862: [debug] Loading project config file stack.yaml
2018-11-14 21:08:50.607796: [debug] Decoding build plan from: /Users/dkatz/.stack/build-plan/lts-12.18.yaml
2018-11-14 21:08:50.607903: [debug] Trying to decode /Users/dkatz/.stack/build-plan-cache/lts-12.18.cache
2018-11-14 21:08:50.616718: [debug] Success decoding /Users/dkatz/.stack/build-plan-cache/lts-12.18.cache
2018-11-14 21:08:50.617396: [debug] Potential GHC builds: standard
2018-11-14 21:08:50.617462: [debug] Found already installed GHC builds: standard
2018-11-14 21:08:50.618666: [debug] Asking GHC for its version
2018-11-14 21:08:50.618910: [debug] Getting Cabal package version
2018-11-14 21:08:50.619023: [debug] Getting global package database location
2018-11-14 21:08:50.619060: [debug] Run process: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc --numeric-version
2018-11-14 21:08:50.619812: [debug] Run process: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
2018-11-14 21:08:50.620426: [debug] Run process: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --no-user-package-db list --global
2018-11-14 21:08:50.673191: [debug] Process finished in 53ms: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --no-user-package-db field --simple-output Cabal version
2018-11-14 21:08:50.677948: [debug] Process finished in 55ms: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --no-user-package-db list --global
2018-11-14 21:08:50.686977: [debug] Process finished in 68ms: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc --numeric-version
2018-11-14 21:08:50.687118: [debug] GHC version is: ghc-8.4.4
2018-11-14 21:08:50.688222: [debug] Resolving package entries
2018-11-14 21:08:50.688433: [debug] Trying to decode /Users/dkatz/.stack/loaded-snapshot-cache/x86_64-osx/ghc-8.4.4/lts-12.18.cache
2018-11-14 21:08:50.724196: [debug] Success decoding /Users/dkatz/.stack/loaded-snapshot-cache/x86_64-osx/ghc-8.4.4/lts-12.18.cache
2018-11-14 21:08:50.724564: [debug] Starting to execute command inside EnvConfig
2018-11-14 21:08:50.724628: [debug] Parsing the targets
2018-11-14 21:08:50.724775: [debug] Running hpack on /Users/dkatz/junk/footest/package.yaml
2018-11-14 21:08:50.730729: [debug] hpack output unchanged in /Users/dkatz/junk/footest/footest.cabal
2018-11-14 21:08:50.744767: [debug] Start: getPackageFiles /Users/dkatz/junk/footest/footest.cabal
2018-11-14 21:08:50.746989: [debug] Finished in 2ms: getPackageFiles /Users/dkatz/junk/footest/footest.cabal
2018-11-14 21:08:50.750101: [debug] Finding out which packages are already installed
2018-11-14 21:08:50.750321: [debug] Run process: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot
2018-11-14 21:08:50.811076: [debug] Process finished in 61ms: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --global --no-user-package-db dump --expand-pkgroot
2018-11-14 21:08:50.811604: [debug] Ignoring package haskeline due to wanting version 0.7.4.3 instead of 0.7.4.2
2018-11-14 21:08:50.813729: [debug] Run process: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --user --no-user-package-db --package-db /Users/dkatz/.stack/snapshots/x86_64-osx/lts-12.18/8.4.4/pkgdb dump --expand-pkgroot
2018-11-14 21:08:50.859183: [debug] Process finished in 45ms: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --user --no-user-package-db --package-db /Users/dkatz/.stack/snapshots/x86_64-osx/lts-12.18/8.4.4/pkgdb dump --expand-pkgroot
2018-11-14 21:08:50.859437: [debug] Run process: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --user --no-user-package-db --package-db /Users/dkatz/junk/footest/.stack-work/install/x86_64-osx/lts-12.18/8.4.4/pkgdb dump --expand-pkgroot
2018-11-14 21:08:50.901070: [debug] Process finished in 42ms: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --user --no-user-package-db --package-db /Users/dkatz/junk/footest/.stack-work/install/x86_64-osx/lts-12.18/8.4.4/pkgdb dump --expand-pkgroot
2018-11-14 21:08:50.901421: [debug] Constructing the build plan
2018-11-14 21:08:50.901967: [debug] Checking if we are going to build multiple executables with the same name
2018-11-14 21:08:50.902043: [debug] Executing the build plan
2018-11-14 21:08:50.902883: [debug] Getting global package database location
2018-11-14 21:08:50.902948: [debug] Run process: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --no-user-package-db list --global
2018-11-14 21:08:50.946244: [debug] Process finished in 43ms: /Users/dkatz/.stack/programs/x86_64-osx/ghc-8.4.4/bin/ghc-pkg --no-user-package-db list --global
2018-11-14 21:08:50.946723: [info] Building all executables for `footest' once. After a successful build of all of them, only specified executables will be rebuilt.
2018-11-14 21:08:50.947163: [debug] Encoding /Users/dkatz/junk/footest/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/lib
2018-11-14 21:08:50.947680: [debug] Finished writing /Users/dkatz/junk/footest/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/lib
2018-11-14 21:08:50.947751: [debug] Encoding /Users/dkatz/junk/footest/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/exe-footest-exe
2018-11-14 21:08:50.948032: [debug] Finished writing /Users/dkatz/junk/footest/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/exe-footest-exe
2018-11-14 21:08:50.948080: [info] footest-0.1.0.0: build (lib + exe)
2018-11-14 21:08:50.948325: [debug] Run process within /Users/dkatz/junk/footest/: /Users/dkatz/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.2.0.1 build lib:footest exe:footest-exe --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
2018-11-14 21:08:51.021121: [info] Preprocessing library for footest-0.1.0.0..
2018-11-14 21:08:51.021275: [info] Building library for footest-0.1.0.0..
2018-11-14 21:08:51.196338: [warn] ar: @.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/objs-9879/ar9879-0.rsp: No such file or directory
2018-11-14 21:08:51.207024: [debug] Start: getPackageFiles /Users/dkatz/junk/footest/footest.cabal
2018-11-14 21:08:51.209876: [debug] Finished in 3ms: getPackageFiles /Users/dkatz/junk/footest/footest.cabal
2018-11-14 21:08:51.210049: [debug] Encoding /Users/dkatz/junk/footest/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/lib
2018-11-14 21:08:51.210476: [debug] Finished writing /Users/dkatz/junk/footest/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/lib
2018-11-14 21:08:51.210554: [debug] Encoding /Users/dkatz/junk/footest/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/exe-footest-exe
2018-11-14 21:08:51.210916: [debug] Finished writing /Users/dkatz/junk/footest/.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/stack-build-caches/exe-footest-exe

--  While building package footest-0.1.0.0 using:
      /Users/dkatz/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.2.0.1 build lib:footest exe:footest-exe --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

Stack version

$ stack --version
Version 1.9.1, Git revision f9d0042c141660e1d38f797e1d426be4a99b2a3c (6168 commits) x86_64 hpack-0.31.0

OS details

$ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.14
BuildVersion:	18A391

$ xcode-select --version
xcode-select version 2354.

Method of installation

  • Official binary, downloaded from stackage.org or fpcomplete's package repository
@jherman3
Copy link

I experience the exact same behavior on the latest update of OSX.

~ ❯❯❯ sw_vers
ProductName:	Mac OS X
ProductVersion:	10.14.1
BuildVersion:	18B75
~ ❯❯❯ xcode-select --version
xcode-select version 2354.

Homebrew GHC/Cabal are not installed, this is with Stack's installation.

@dpkatz
Copy link
Author

dpkatz commented Nov 16, 2018

I should add that I also saw this behavior on the last version of Mac OS X "High Sierra" (10.13.6). This is why I think it's tied to the release of the build tools rather than a more generic OS version issue.

@jherman3
Copy link

I think this started happening to me right after I upgraded OSX build tools / Xcode but I'm not sure. It was definitely after some sort of update.

@dbaynard
Copy link
Contributor

Ah, that sounds worrying. Have you tried stack clean --full, or reinstalling the compiler?

@jherman3
Copy link

Running after stack clean --full still has the problem, and I've also tried deleting ~/.stack to reinstall the compiler and start fresh. This happens without system (homebrew) GHC installed.

@dbaynard
Copy link
Contributor

I've seen macOS issues where the solution was to remove just the ~/.stack/setup-exe-cache/ folder — though it wasn't clear why.

Mind, seeing that .rsp error — could be a gcc/clang issue?

@jherman3
Copy link

I tried using Homebrew's gcc-4.9 and gcc-8 as the compiler (specified in stack.yaml with with-gcc: /path/to/gcc) and the result is the same.

@dbaynard
Copy link
Contributor

Could it be an incompatibility between stack and the MacOS command line tools?

This could very well be the case. I think I've seen some issues with with-gcc — that might be somewhere to look.

A maintainer has failed to reproduce this on macOS.

@jherman3 It would be good to see precisely what you have tried — for example, the stack.yaml you mention, and any differences from @dpkatz's description.

@jherman3
Copy link

I tried setting it up with no modifications to the defaults, see this gist for the stack.yaml file and the terminal output. The results were the same whether I specified with-gcc on the command line like in the gist or in the stack.yaml file.

@dbaynard
Copy link
Contributor

Have you @jherman3 @dpkatz seen #4380? I note that there's an ar error in the first log, too.

@jherman3 please update the gist with --verbose logs if that issue doesn't help.

@dpkatz
Copy link
Author

dpkatz commented Nov 20, 2018

I saw #4380, but couldn't see anything there that's relevant for me. I don't have macports installed, and I uninstalled binutils from homebrew; as far as I know, the Apple supplied ar (and ranlib for that matter) are the only ones on my box.

I also ran xcode-select --install:

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

@jherman3
Copy link

jherman3 commented Nov 20, 2018

I also did not find anything in that issue that resolves the issue. I don't have Homebrew binutils installed or any other tools on my PATH that would interfere. The result is the same after running xcode-select --install. Here's a gist with verbose logging. I also ran the command that failed with the -v option to get more output if that's useful at all.

@cideM
Copy link

cideM commented Nov 30, 2018

Hm I have what is maybe related issue. I'm on MacoS Mojave 10.14.1 using Stack 1.9.1

If I follow the Quick Start from the Stack docs I get

Undefined symbols for architecture x86_64:
  "_myzmprojectzm0zi1zi0zi0zmBuPYVrlKTDcHo9TFCxWh7J_Lib_someFunc1_closure", referenced from:
      _Main_main1_info in Main.o
      _S31U_srt in Main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
`gcc' failed in phase `Linker'. (Exit code: 1)

--  While building package my-project-0.1.0.0 using:
      /Users/yuuki/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.4 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.2.0.1 build lib:my-project exe:my-project-exe --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1

for stack build

UPDATE: Solved by moving /usr/bin before /usr/local/bin and re-installing stack globally and project-wide as outlined in #3487

@dpkatz
Copy link
Author

dpkatz commented Dec 5, 2018

I just updated to stack-1.9.3 (from homebrew) and started with a fresh .stack directory, and now it all seems to be working. No idea what changed...

@jherman3 - want to give that a try?

@jherman3
Copy link

jherman3 commented Dec 5, 2018

Updating Stack via homebrew and rm -rf ~/.stack fixed the issue for me as well.

@dpkatz
Copy link
Author

dpkatz commented Dec 5, 2018

Well, that would seem to settle that, though I wish I knew what caused the root problem and what changed.

Anyway, I'll close this issue.

@dpkatz dpkatz closed this as completed Dec 5, 2018
@Congee
Copy link

Congee commented Dec 29, 2018

rm -rf ~/.stack doesn't work for me. but stack clean worked

@mihaimaruseac
Copy link
Contributor

stack clean cleans .stack-work in the current project, ~/.stack is the global snapshot. Sometimes you need to clear both, sometimes only one of them, depending on the specific error.

@nh2
Copy link
Collaborator

nh2 commented Feb 4, 2019

There's also some chance that this is due to an interrupted build: https://github.com/lehins/exec-kill-loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants