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

GHCJS build worked only once and then stack simply stopped doing anything in consecutive builds #3665

Closed
tolgap opened this issue Dec 17, 2017 · 5 comments

Comments

@tolgap
Copy link

tolgap commented Dec 17, 2017

General summary/comments

I'm using a backend/frontend structure using GHCJS and GHC. There are 2 directories backend and frontend with each their own stack.yaml. I managed to compile the frontend only once, and any consecutive commands to stack simply stopped giving any output.

Steps to reproduce

I am not sure what produces this issue. The install command worked once, but after that it simply stopped working. But here is my cabal and stack file:

# frontend/stack.yaml

resolver: lts-8.11
compiler: ghcjs-0.2.1.9008011_ghc-8.0.2
compiler-check: match-exact
setup-info:
  ghcjs:
    source:
      ghcjs-0.2.1.9008011_ghc-8.0.2:
        url: https://github.com/matchwood/ghcjs-stack-dist/raw/master/ghcjs-0.2.1.9008011.tar.gz
        sha1: a72a5181124baf64bcd0e68a8726e65914473b3b
packages:
  - '..'
extra-deps:
  - miso-0.10.0.0
  - aeson-1.1.0.0
name:                miso-test
version:             0.1.0.0
synopsis:            First miso app
category:            Web
build-type:          Simple
cabal-version:       >=1.10

executable frontend
    main-is:
        Main.hs
    if !impl(ghjs)
        buildable: False
    else
        ghcjs-options:
            -dedupe
        hs-source-dirs:
            frontend, common
        build-depends:
            aeson,
            base < 5,
            containers,
            miso
    default-language:
        Haskell2010

And then I run

$ stack install --stack-yaml=frontend/stack.yaml

Expected

I expect there to be a build and a copy of the jsexe to my .stack-work bin directory

Actual

What actually happens is nothing... When I run it in verbose mode:

$ stack install --stack-yaml=frontend/stack.yaml --verbose
Version 1.6.1 x86_64 hpack-0.20.0
2017-12-17 11:55:46.679175: [debug] Loading project config file frontend/stack.yaml
@(Stack/Config.hs:868:13)
2017-12-17 11:55:46.684059: [debug] Decoding build plan from: /Users/tolga/.stack/build-plan/lts-8.11.yaml
@(Stack/Snapshot.hs:150:5)
2017-12-17 11:55:46.684341: [debug] Trying to decode /Users/tolga/.stack/build-plan-cache/lts-8.11.cache
@(Data/Store/VersionTagged.hs:66:5)
2017-12-17 11:55:46.697125: [debug] Success decoding /Users/tolga/.stack/build-plan-cache/lts-8.11.cache
@(Data/Store/VersionTagged.hs:70:13)
2017-12-17 11:55:46.711679: [debug] Run process: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs
@(System/Process/Log.hs:37:3)
2017-12-17 11:55:46.861391: [debug] Getting global package database location
@(Stack/GhcPkg.hs:46:5)
2017-12-17 11:55:46.861675: [debug] Run process: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs-pkg --no-user-package-db list --global
@(System/Process/Log.hs:37:3)
2017-12-17 11:55:46.861799: [debug] Asking GHCJS for its version
@(Stack/Setup/Installed.hs:105:13)
2017-12-17 11:55:46.862554: [debug] Getting Cabal package version
@(Stack/GhcPkg.hs:185:5)
2017-12-17 11:55:46.862695: [debug] Run process: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs --version
@(System/Process/Log.hs:37:3)
2017-12-17 11:55:46.862846: [debug] Run process: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs-pkg --no-user-package-db field --simple-output Cabal version
@(System/Process/Log.hs:37:3)
2017-12-17 11:55:46.899312: [debug] Process finished in 36ms: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs --version
@(System/Process/Log.hs:44:3)
2017-12-17 11:55:46.907402: [debug] Process finished in 43ms: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs-pkg --no-user-package-db field --simple-output Cabal version
@(System/Process/Log.hs:44:3)
2017-12-17 11:55:46.915143: [debug] Process finished in 53ms: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs-pkg --no-user-package-db list --global
@(System/Process/Log.hs:44:3)
2017-12-17 11:55:46.915451: [debug] Resolving package entries
@(Stack/Setup.hs:252:5)
2017-12-17 11:55:46.915597: [debug] Trying to decode /Users/tolga/.stack/loaded-snapshot-cache/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/lts-8.11.cache
@(Data/Store/VersionTagged.hs:66:5)
2017-12-17 11:55:46.978096: [debug] Success decoding /Users/tolga/.stack/loaded-snapshot-cache/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/lts-8.11.cache
@(Data/Store/VersionTagged.hs:70:13)
2017-12-17 11:55:46.978944: [debug] Starting to execute command inside EnvConfig
@(Stack/Runners.hs:170:18)
2017-12-17 11:55:46.979061: [debug] Parsing the targets
@(Stack/Build/Target.hs:460:3)
2017-12-17 11:55:46.980544: [debug] Trying to decode /Users/tolga/.stack/indices/Hackage/01-index.cache
@(Data/Store/VersionTagged.hs:66:5)
2017-12-17 11:55:47.202006: [debug] Success decoding /Users/tolga/.stack/indices/Hackage/01-index.cache
@(Data/Store/VersionTagged.hs:70:13)
2017-12-17 11:55:47.251070: [debug] Exception ignored when attempting to load /Users/tolga/Work/Paramander/miso-test/.stack-work/dist/x86_64-osx/Cabal-1.24.2.0_ghcjs/stack-build-cache: /Users/tolga/Work/Paramander/miso-test/.stack-work/dist/x86_64-osx/Cabal-1.24.2.0_ghcjs/stack-build-cache: openBinaryFile: does not exist (No such file or directory)
@(Data/Store/VersionTagged.hs:84:9)
2017-12-17 11:55:47.251556: [debug] Start: getPackageFiles /Users/tolga/Work/Paramander/miso-test/miso-test.cabal
@(Stack/PrettyPrint.hs:134:16)
2017-12-17 11:55:47.251910: [debug] Finished in 0ms: getPackageFiles /Users/tolga/Work/Paramander/miso-test/miso-test.cabal
@(Stack/PrettyPrint.hs:134:16)
2017-12-17 11:55:47.254275: [debug] Finding out which packages are already installed
@(Stack/Build/Installed.hs:60:5)
2017-12-17 11:55:47.255076: [debug] Run process: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs-pkg --global --no-user-package-db dump --expand-pkgroot
@(System/Process/Log.hs:37:3)
2017-12-17 11:55:47.329156: [debug] Process finished in 73ms: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs-pkg --global --no-user-package-db dump --expand-pkgroot
@(System/Process/Log.hs:44:3)
2017-12-17 11:55:47.330080: [debug] Ignoring package ghcjs-base due to wrong location: (Nothing,Local)
@(Stack/Build/Installed.hs:190:5)
2017-12-17 11:55:47.330212: [debug] Ignoring package aeson due to wrong location: (Nothing,Local)
@(Stack/Build/Installed.hs:190:5)
2017-12-17 11:55:47.331270: [debug] Run process: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs-pkg --user --no-user-package-db --package-db /Users/tolga/.stack/snapshots/x86_64-osx/lts-8.11/ghcjs-0.2.1.9008011_ghc-8.0.2/pkgdb dump --expand-pkgroot
@(System/Process/Log.hs:37:3)
2017-12-17 11:55:47.374001: [debug] Process finished in 42ms: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs-pkg --user --no-user-package-db --package-db /Users/tolga/.stack/snapshots/x86_64-osx/lts-8.11/ghcjs-0.2.1.9008011_ghc-8.0.2/pkgdb dump --expand-pkgroot
@(System/Process/Log.hs:44:3)
2017-12-17 11:55:47.374793: [debug] Ignoring package servant, from (InstalledTo Snap,"/Users/tolga/.stack/snapshots/x86_64-osx/lts-8.11/ghcjs-0.2.1.9008011_ghc-8.0.2/pkgdb/"), due to wrong location: (Just (InstalledTo Snap),Local)
@(Stack/Build/Installed.hs:190:5)
2017-12-17 11:55:47.375968: [debug] Run process: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs-pkg --user --no-user-package-db --package-db /Users/tolga/Work/Paramander/miso-test/frontend/.stack-work/install/x86_64-osx/lts-8.11/ghcjs-0.2.1.9008011_ghc-8.0.2/pkgdb dump --expand-pkgroot
@(System/Process/Log.hs:37:3)
2017-12-17 11:55:47.408941: [debug] Process finished in 32ms: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs-pkg --user --no-user-package-db --package-db /Users/tolga/Work/Paramander/miso-test/frontend/.stack-work/install/x86_64-osx/lts-8.11/ghcjs-0.2.1.9008011_ghc-8.0.2/pkgdb dump --expand-pkgroot
@(System/Process/Log.hs:44:3)
2017-12-17 11:55:47.427808: [debug] Constructing the build plan
@(Stack/Build/ConstructPlan.hs:180:5)
2017-12-17 11:55:47.428160: [debug] Checking if we are going to build multiple executables with the same name
@(Stack/Build.hs:177:5)
2017-12-17 11:55:47.428276: [debug] Executing the build plan
@(Stack/Build/Execute.hs:490:5)
2017-12-17 11:55:47.429130: [debug] Getting global package database location
@(Stack/GhcPkg.hs:46:5)
2017-12-17 11:55:47.429312: [debug] Run process: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs-pkg --no-user-package-db list --global
@(System/Process/Log.hs:37:3)
2017-12-17 11:55:47.465621: [debug] Process finished in 36ms: /Users/tolga/.stack/programs/x86_64-osx/ghcjs-0.2.1.9008011_ghc-8.0.2/bin/ghcjs-pkg --no-user-package-db list --global
@(System/Process/Log.hs:44:3)

Stack version

$ stack --version
Version 1.6.1 x86_64 hpack-0.20.0

Method of installation

I installed stack using brew, and its the latest version right now.

@mgsloan
Copy link
Contributor

mgsloan commented Dec 17, 2017

Unfortunately, I ran into an issue with using Cabal-2.0 along with this build - haskell/cabal#4137 (comment) - and don't currently feel like putting much more time into reproducing it.

One thing to try varying is your node version. Sometimes that can be a source of non reproducibility of ghcjs builds. It would be nice to have stack manage this - #1632 - but that's not currently implemented. It's hard to figure out what all the different behaviors are on different node versions. node 6.10.0 is what I have and that seems to work pretty well.

Even trickier is that sometimes node version actually affects compilation results, and so you don't actually see the problems get fixed unless the stuff is rebuilt.

@tolgap
Copy link
Author

tolgap commented Dec 18, 2017

I've tried many node versions, but it did not fix my issue. I'm starting to think my ~/.stack cache directory might be corrupted, because it just stops doing anything after discovering my global packages in the snapshot (as you can see in the last lines of the log I put in my issue). I guess I'll have to nuke my ghcjs related things, and rebuild everything with an older version of node to see if that fixes it.

@mgsloan
Copy link
Contributor

mgsloan commented Dec 18, 2017

Sorry that didn't work out, I hope you figure it out soon! I know that getting this stuff working can be frustrating. It was even harder before stack setup.

Note that ghcjs puts some of its packages in ~/.ghcjs, would probably be good to instead put them somewhere within STACK_ROOT

@tolgap
Copy link
Author

tolgap commented Dec 18, 2017

No need to apologize, I'm sure I'm doing something wrong 😄 .

Could you expand on "put them somewhere within STACK_ROOT" ? These are the relevant contents of .ghcjs/myversion-ghcjs:
screen shot 2017-12-18 at 11 23 44

Where should I put these exactly?

@tolgap
Copy link
Author

tolgap commented Dec 18, 2017

@mgsloan I've found the culprit 😄 .

I used a single Cabal file, with two executables (frontend and backend).

The file was like this:

executable backend
  if impl(ghcjs)
    buildable: False
  else
    ...

executable frontend
  if !impl(ghcjs)
    buildable: False
  else
    ...

I had this setup from a tutorial I was following, but it simply didn't work this way. I split it up into two Cabal files (one for frontend and one for backend) and it started working.

I knew I was doing something wrong 😅 .

@tolgap tolgap closed this as completed Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants