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 fails for "Hello World" executable project with error: ghc-pkg: cannot find package #1232

Closed
VictorTaelin opened this issue Oct 25, 2015 · 6 comments

Comments

@VictorTaelin
Copy link

Stack is failing to build a "Hello World" executable here. Here is the log:

$ mkdir Aff

$ cd Aff

$ echo "main = print \"hello world\"" >> Main.hs

$ cabal init

Package name? [default: Aff]
Package version? [default: 0.1.0.0]
Please choose a license:
* 1) (none)
2) GPL-2
3) GPL-3
4) LGPL-2.1
5) LGPL-3
6) AGPL-3
7) BSD2
8) BSD3
9) MIT
10) ISC
11) MPL-2.0
12) Apache-2.0
13) PublicDomain
14) AllRightsReserved
15) Other (specify)
Your choice? [default: (none)]
Author name? [default: V]
Maintainer email? [default: v]
Project homepage URL?
Project synopsis?
Project category:
* 1) (none)
2) Codec
3) Concurrency
4) Control
5) Data
6) Database
7) Development
8) Distribution
9) Game
10) Graphics
11) Language
12) Math
13) Network
14) Sound
15) System
16) Testing
17) Text
18) Web
19) Other (specify)
Your choice? [default: (none)]
What does the package build:
1) Library
2) Executable
Your choice? 2
What is the main module of the executable:
* 1) Main.hs
2) Other (specify)
Your choice? [default: Main.hs]
What base language is the package written in:
* 1) Haskell2010
2) Haskell98
3) Other (specify)
Your choice? [default: Haskell2010]
Include documentation on what each field means (y/n)? [default: n]
Source directory:
* 1) (none)
2) src
3) Other (specify)
Your choice? [default: (none)]

Guessing dependencies...

Generating LICENSE...
Warning: unknown license type, you must put a copy in LICENSE yourself.
Generating Setup.hs...
Generating Aff.cabal...

Warning: no synopsis given. You should edit the .cabal file and add one.
You may want to edit the .cabal file and add a Description field.

$ stack init

Writing default config file to: /Users/v/Aff/stack.yaml
Basing on cabal files:
- /Users/v/Aff/Aff.cabal

Checking against build plan lts-3.7
Selected resolver: lts-3.7
Wrote project config to: /Users/v/Aff/stack.yaml

$ echo "AFF" >> LICENSE

$ stack build

Aff-0.1.0.0: build
Preprocessing executable 'Aff' for Aff-0.1.0.0...
Aff-0.1.0.0: copy/register
Installing executable(s) in
/Users/v/Aff/.stack-work/install/x86_64-osx/lts-3.7/7.10.2/bin
Package contains no library to register: Aff-0.1.0.0...
Running /Applications/ghc-7.10.2.app/Contents/bin/ghc-pkg --user --no-user-package-db --package-db /Users/v/Aff/.stack-work/install/x86_64-osx/lts-3.7/7.10.2/pkgdb/ describe --simple-output Aff --expand-pkgroot exited with ExitFailure 1

ghc-pkg: cannot find package Aff

Moreover, it is failing to build a project that was building fine until yesterday, and nothing changed on it. The project is available at http://github.com/maiavictor/haelin. The error is similar: ghc-pkg: cannot find package Test (which is the only executable inside my project). The only thing I did was update stack to enable GHCJS, as suggested on the GHCJS thread:

stack upgrade --git

This is the version I have:

Vs-MacBook:~ v$ stack --version
Version 0.1.7.0, Git revision 33462aba13f85a3d5c1690c6ee0bb3dd4af6b616 x86_64

I'm under OSX El Capitain.

@snoyberg
Copy link
Contributor

I think I know what's happening...

@snoyberg snoyberg added this to the P1: Must milestone Oct 25, 2015
@snoyberg snoyberg self-assigned this Oct 25, 2015
@snoyberg
Copy link
Contributor

Out of curiosity: what's your stack exec -- ghc-pkg list Cabal output look like?

My guess is that this broke due to my change to use the register command to Cabal (due to a Cabal bug around post install hooks). I'm unable to reproduce this issue myself, but perhaps there's an OS or Cabal version issue at play. In any event, saying "only register if there's a library" is simple enough.

@snoyberg
Copy link
Contributor

@MaiaVictor I believe this should now be fixed on master. After pulling the latest master, I was also able to reproduce this problem, and it was unrelated to the code change I thought it might be part of.

Can you confirm that after stack upgrade --git this works?

@VictorTaelin
Copy link
Author

@snoyberg I am really sorry for the delay! I've left stack upgrading and will tell you whether it works as soon as I get back from work. The output of stack exec -- ghc-pkg list Cabal looks like:

Run from outside a project, using implicit global project config
Using resolver: lts-3.7 from implicit global project's config file: /Users/v/.stack/global/stack.yaml
/Applications/ghc-7.10.2.app/Contents/lib/ghc-7.10.2/package.conf.d
Cabal-1.22.4.0
/Users/v/.stack/snapshots/x86_64-osx/lts-3.7/7.10.2/pkgdb
/Users/v/.stack/global/.stack-work/install/x86_64-osx/lts-3.7/7.10.2/pkgdb

@VictorTaelin
Copy link
Author

Okay, turns out it updated quite quickly so I was able to test it already. Seems like everything works. Thank you!

@snoyberg
Copy link
Contributor

No problem

dysinger added a commit that referenced this issue Nov 13, 2015
* master: (106 commits)
  Fix ghci -package-id for lib dep from test #1222
  Fix passing of include dirs to GHCI #1222
  Minor change to some local var naming
  Fix a copy-o which breaks ghci test targets #1222
  Only ask for commit count once when compiling
  Move Windows installers above manual download
  Import all modules after loading them (#995)
  replace if then else with case matching (multiway if)
  Control/Concurrent/Execute.hs : redundant do
  Use stack setup so you can ignore most of the output
  Don't cache the GHC folder
  Strip -static before passing to GHCi (#1094)
  Fix: unlisted files in tests and benchmarks trigger extraneous second build (fixes #838)
  Don't fail when registering/looking up library for executable-only packages #1232
  Fix help for default true bool flag's enable hint
  Rebuild when cabal file is changed
  watched command: show files, not directories
  Update changelog
  Fix: Haddocks not copied for dependencies (fixes #1105)
  Remove redundant Version from InstalledMap
  ...
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

3 participants