Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Error with ghc-mod on CabalHelper/Licenses.hs:56:8 #905

Open
Tehnix opened this issue Aug 22, 2017 · 14 comments
Open

Error with ghc-mod on CabalHelper/Licenses.hs:56:8 #905

Tehnix opened this issue Aug 22, 2017 · 14 comments

Comments

@Tehnix
Copy link

Tehnix commented Aug 22, 2017

I seem to be getting the same error as reported in #831 whenever I try to run ghc-mod check src/Parser.hs.

ghc-mod was installed with stackage LTS 9.1, which seems to bring

λ ~ $ ghc-mod --version
ghc-mod version 5.8.0.0 compiled by GHC 8.0.2

and internally use cabal-helper 7.3.0 (at least according to stackage.org).

The earlier issue I referenced seemed to have it solved by updating either ghc-mod or cabal-helper, but both should be in sync here using the newest versions.

λ Haskell/Haskell-LLVM $ ghc-mod check src/Parser.hs
[1 of 5] Compiling CabalHelper.Types ( CabalHelper/Types.hs, /Users/tehnix/.ghc-mod/cabal-helper/CabalHelper/Types.o )
[2 of 5] Compiling CabalHelper.Sandbox ( CabalHelper/Sandbox.hs, /Users/tehnix/.ghc-mod/cabal-helper/CabalHelper/Sandbox.o )
[3 of 5] Compiling CabalHelper.Licenses ( CabalHelper/Licenses.hs, /Users/tehnix/.ghc-mod/cabal-helper/CabalHelper/Licenses.o )

CabalHelper/Licenses.hs:56:8: error:
    • Expecting one more argument to ‘CPackageIndex ModuleName’
      Expected a type, but ‘CPackageIndex ModuleName’ has kind ‘* -> *’
    • In the type signature:
        findTransitiveDependencies :: CPackageIndex ModuleName
                                      -> Set CInstalledPackageId -> Set CInstalledPackageId
ghc-mod: readCreateProcess: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2/libexec/x86_64-osx-ghc-8.0.2/cabal-helper-0.7.3.0/cabal-helper-wrapper "--with-ghc=/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc" "--with-ghc-pkg=/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc-pkg" "--with-cabal=cabal" "/Users/tehnix/Dropbox/__Synced/Testing/Haskell/Haskell-LLVM" "/Users/tehnix/Dropbox/__Synced/Testing/Haskell/Haskell-LLVM/.stack-work/dist/x86_64-osx/Cabal-2.0.0.2" "package-db-stack" "entrypoints" "source-dirs" "ghc-options" "ghc-src-options" "ghc-pkg-options" "ghc-merged-pkg-options" "ghc-lang-options" "licenses" "flags" "config-flags" "non-default-config-flags" "compiler-version" (exit 1): failed

I can also upload my source code that I'm trying it on it that helps. All the stack.yaml contains is resolver: lts-9.1.

@DanielG
Copy link
Owner

DanielG commented Aug 22, 2017

I think you're using a stackage nightly in your project which has Cabal-2.x already, actually I can see that from the output above. That isn't supported by cabal-helper-0.7.x. The release of c-h-0.8 is pending the merging and deployment on hackage of haskell/cabal#4714. After that we will need to release a version of ghc-mod compatible with c-h-0.8 which is the easy part.

For now you'll have to use lts-9.1 in your project (which appears to still have Cabal-1.24), sorry.

@Tehnix
Copy link
Author

Tehnix commented Aug 24, 2017

@DanielG thanks! You're right.

I have no idea how it ended in that state, nuking the .stack-work dir in the folder seems to output the same. I don't know if stack or ghc-mod keeps something cached somewhere :/

@DanielG
Copy link
Owner

DanielG commented Aug 24, 2017

You did change the resolver: __ setting in stack.yaml, right?

@Tehnix
Copy link
Author

Tehnix commented Aug 28, 2017

Yeah, it's a bit of a weird issue with this folder only.

The stack.yaml,

resolver: lts-9.1
packages:
- .
extra-deps: []
flags: {}
extra-package-dbs: []

Running ghc-mod check src/Parser.hs,

[1 of 5] Compiling CabalHelper.Types ( CabalHelper/Types.hs, /Users/tehnix/.ghc-mod/cabal-helper/CabalHelper/Types.o )
[2 of 5] Compiling CabalHelper.Sandbox ( CabalHelper/Sandbox.hs, /Users/tehnix/.ghc-mod/cabal-helper/CabalHelper/Sandbox.o )
[3 of 5] Compiling CabalHelper.Licenses ( CabalHelper/Licenses.hs, /Users/tehnix/.ghc-mod/cabal-helper/CabalHelper/Licenses.o )

CabalHelper/Licenses.hs:56:8: error:
    • Expecting one more argument to ‘CPackageIndex ModuleName’
      Expected a type, but ‘CPackageIndex ModuleName’ has kind ‘* -> *’
    • In the type signature:
        findTransitiveDependencies :: CPackageIndex ModuleName
                                      -> Set CInstalledPackageId -> Set CInstalledPackageId
ghc-mod: readCreateProcess: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2/libexec/x86_64-osx-ghc-8.0.2/cabal-helper-0.7.3.0/cabal-helper-wrapper "--with-ghc=/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc" "--with-ghc-pkg=/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc-pkg" "--with-cabal=cabal" "/Users/tehnix/Dropbox/__Synced/Testing/Haskell/Haskell-LLVM" "/Users/tehnix/Dropbox/__Synced/Testing/Haskell/Haskell-LLVM/.stack-work/dist/x86_64-osx/Cabal-2.0.0.2" "package-db-stack" "entrypoints" "source-dirs" "ghc-options" "ghc-src-options" "ghc-pkg-options" "ghc-merged-pkg-options" "ghc-lang-options" "licenses" "flags" "config-flags" "non-default-config-flags" "compiler-version" (exit 1): failed

The cabal file contains,

name: Haskell-LLVM
version: 0.1.0.0
cabal-version: >=1.10
build-type: Simple
license: BSD3
license-file: LICENSE
copyright: Christian Kjaer Laustsen
maintainer: ckl@codetalk.io
category: Compiler
author: Christian Kjaer Laustsen
extra-source-files:
    README.md

library
    exposed-modules:
        Parser
        Lexer
        Syntax
    build-depends:
        base >=4.7 && <5,
        parsec -any
    default-language: Haskell2010
    hs-source-dirs: src

executable Haskell-LLVM-exe
    main-is: Main.hs
    build-depends:
        base -any,
        haskeline -any,
        mtl -any,
        Haskell-LLVM -any
    default-language: Haskell2010
    hs-source-dirs: app
    ghc-options: -threaded -rtsopts -with-rtsopts=-N

Also, I got it working outside of this, so it's not a pressing issue by any means, but I am still interested in what might be wrong though :)

@DanielG
Copy link
Owner

DanielG commented Aug 28, 2017

Very strange. If $ stack path also mentions that path: "/Users/tehnix/Dropbox/__Synced/Testing/Haskell/Haskell-LLVM/.stack-work/dist/x86_64-osx/Cabal-2.0.0.2" (note the Cabal-2.0.0.2 bit) this sounds like a stack bug I guess. According to https://www.stackage.org/lts-9.1/package/Cabal the Cabal version should be 1.24 for lts-9.1.

@Tehnix
Copy link
Author

Tehnix commented Aug 30, 2017

Hmm,

I get (globally),

λ ~ $ stack path
stack-root: /Users/tehnix/.stack
project-root: /Users/tehnix/.stack/global-project
config-location: /Users/tehnix/.stack/global-project/stack.yaml
bin-path: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2/bin:/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin:/Users/tehnix/.rbenv/plugins/ruby-build/bin:/Users/tehnix/.rbenv/shims:/Users/tehnix/.rbenv/bin:/Users/tehnix/.local/bin:/usr/local/opt/pyenv/shims:/usr/local/opt/pyenv/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/Users/tehnix/.nix-profile/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
programs: /Users/tehnix/.stack/programs/x86_64-osx
compiler-exe: /Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc
compiler-bin: /Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin
local-bin: /Users/tehnix/.local/bin
extra-include-dirs:
extra-library-dirs:
snapshot-pkg-db: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2/pkgdb
local-pkg-db: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.1/8.0.2/pkgdb
global-pkg-db: /Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
ghc-package-path: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.1/8.0.2/pkgdb:/Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2/pkgdb:/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
snapshot-install-root: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2
local-install-root: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.1/8.0.2
snapshot-doc-root: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2/doc
local-doc-root: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.1/8.0.2/doc
dist-dir: .stack-work/dist/x86_64-osx/Cabal-2.0.0.2
local-hpc-root: /Users/tehnix/.stack/global-project/.stack-work/install/x86_64-osx/lts-9.1/8.0.2/hpc
local-bin-path: /Users/tehnix/.local/bin
ghc-paths: /Users/tehnix/.stack/programs/x86_64-osx

And inside my project,

λ Haskell/Haskell-LLVM $ stack path
stack-root: /Users/tehnix/.stack
project-root: /Users/tehnix/Dropbox/__Synced/Testing/Haskell/Haskell-LLVM
config-location: /Users/tehnix/Dropbox/__Synced/Testing/Haskell/Haskell-LLVM/stack.yaml
bin-path: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2/bin:/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin:/Users/tehnix/.rbenv/plugins/ruby-build/bin:/Users/tehnix/.rbenv/shims:/Users/tehnix/.rbenv/bin:/Users/tehnix/.local/bin:/usr/local/opt/pyenv/shims:/usr/local/opt/pyenv/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/Users/tehnix/.nix-profile/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
programs: /Users/tehnix/.stack/programs/x86_64-osx
compiler-exe: /Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin/ghc
compiler-bin: /Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/bin
local-bin: /Users/tehnix/.local/bin
extra-include-dirs:
extra-library-dirs:
snapshot-pkg-db: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2/pkgdb
local-pkg-db: /Users/tehnix/Dropbox/__Synced/Testing/Haskell/Haskell-LLVM/.stack-work/install/x86_64-osx/lts-9.1/8.0.2/pkgdb
global-pkg-db: /Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
ghc-package-path: /Users/tehnix/Dropbox/__Synced/Testing/Haskell/Haskell-LLVM/.stack-work/install/x86_64-osx/lts-9.1/8.0.2/pkgdb:/Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2/pkgdb:/Users/tehnix/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
snapshot-install-root: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2
local-install-root: /Users/tehnix/Dropbox/__Synced/Testing/Haskell/Haskell-LLVM/.stack-work/install/x86_64-osx/lts-9.1/8.0.2
snapshot-doc-root: /Users/tehnix/.stack/snapshots/x86_64-osx/lts-9.1/8.0.2/doc
local-doc-root: /Users/tehnix/Dropbox/__Synced/Testing/Haskell/Haskell-LLVM/.stack-work/install/x86_64-osx/lts-9.1/8.0.2/doc
dist-dir: .stack-work/dist/x86_64-osx/Cabal-2.0.0.2
local-hpc-root: /Users/tehnix/Dropbox/__Synced/Testing/Haskell/Haskell-LLVM/.stack-work/install/x86_64-osx/lts-9.1/8.0.2/hpc
local-bin-path: /Users/tehnix/.local/bin
ghc-paths: /Users/tehnix/.stack/programs/x86_64-osx

Notably the dist-dir: .stack-work/dist/x86_64-osx/Cabal-2.0.0.2.

I tried rm'ing the .stack-work directory again in my project, doing stack install ghc-mod, but I still end up at the same point. I don't really know where the dist-dir entry is getting set.

Should I move this over to stack's issue tracker instead?

@DanielG
Copy link
Owner

DanielG commented Sep 4, 2017

Sounds like a plan, I really have no idea why Stack would have the Cabal version used to build projects deviate from the one in the stackage snapshot..

@Tehnix
Copy link
Author

Tehnix commented Sep 5, 2017

Moved to commercialhaskell/stack#3417.

@Tehnix
Copy link
Author

Tehnix commented Sep 5, 2017

To sum up how I fixed it (although still remains how it got there), I went to ~/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d where there was a Cabal-2.0.0.2-1HTE9d8rwAi7gJIdEHeKh7.conf present, along with Cabal-1.24.2.0.conf. I deleted Cabal-2.0.0.2-1HTE9d8rwAi7gJIdEHeKh7.conf and now ghc-mod works.

So:

  • $ rm ~/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d/Cabal-2.0.0.2*

You can probably close this issue here, since this seems to be entirely on the stack side of things.

@mithrandi
Copy link

haskell/cabal#4714 is now merged, but I can't tell if it's deployed on Hackage. Any idea where to check on the status of this?

@DanielG
Copy link
Owner

DanielG commented Nov 19, 2017

We've made progress since the but cabal-helper remains the blocker. See #900 (comment).

@jwiegley
Copy link

Note that this same problem is an issue for recent Nix.

@decentral1se
Copy link

I really have no idea why Stack would have the Cabal version used to build projects deviate from the one in the stackage snapshot..

FYI commercialhaskell/stack#3049 👍

@decentral1se
Copy link

decentral1se commented Dec 23, 2017

So, with #900 (comment), this can move forward?

EDIT: Ah, that's you also hacking over there - sorry for the noise.

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

No branches or pull requests

5 participants