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

Could not find module ‘System.Directory’ although package present @ build-depends in .cabal file #2380

Closed
23ua opened this issue Jul 16, 2016 · 4 comments

Comments

@23ua
Copy link

23ua commented Jul 16, 2016

Could not find module ‘System.Directory’ although package present @ build-depends in .cabal file.
(Not sure but this might be related to #941 #897)

You could clone minimal project that reproduces the issue and a bit more info here.
(I was able to reproduce this on OS X & linux.)

Steps to reproduce:

  1. Create new project with stack new stack-directory-problem
  2. Add directory to build-depends in stack-directory-problem.cabal
  3. Add import System.Directory somewhere in the code.
  4. Run command stack build.

Expected:
Stack builds project successfully.

Actual:

Could not find module ‘System.Directory’
It is a member of the hidden package ‘directory-1.2.2.0@direc_0hFG6ZxK1nk4zsyOqbNHfm’.
Perhaps you need to add ‘directory’ to the build-depends in your .cabal file.

Here is the stack --version output:

$ stack --version
Version 1.1.2 x86_64 hpack-0.14.1```

Here is the command I ran with --verbose

$ stack build --verbose
Version 1.1.2 x86_64 hpack-0.14.1
2016-07-16 21:19:45.433217: [debug] Checking for project config at: /home/username/stack-directory-problem/stack.yaml @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Config src/Stack/Config.hs:811:9)
2016-07-16 21:19:45.433877: [debug] Loading project config file stack.yaml @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Config src/Stack/Config.hs:829:13)
2016-07-16 21:19:45.437309: [debug] Checking whether stack was built with libgmp4 @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Config src/Stack/Config.hs:326:5)
2016-07-16 21:19:45.437775: [debug] Run process: ldd /usr/bin/stack @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:System.Process.Read src/System/Process/Read.hs:283:3)
2016-07-16 21:19:45.454592: [debug] Stack was not built with libgmp4 @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Config src/Stack/Config.hs:330:14)
2016-07-16 21:19:45.455541: [debug] Trying to decode /home/username/.stack/build-plan-cache/x86_64-linux/lts-6.7.cache @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Data.Binary.VersionTagged src/Data/Binary/VersionTagged.hs:55:5)
2016-07-16 21:19:45.499785: [debug] Success decoding /home/username/.stack/build-plan-cache/x86_64-linux/lts-6.7.cache @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Data.Binary.VersionTagged src/Data/Binary/VersionTagged.hs:64:13)
2016-07-16 21:19:45.500385: [debug] Getting system compiler version @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Setup src/Stack/Setup.hs:341:17)
2016-07-16 21:19:45.501761: [debug] Asking GHC for its version @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Setup.Installed src/Stack/Setup/Installed.hs:94:13)
2016-07-16 21:19:45.502425: [debug] Run process: ghc --numeric-version @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:System.Process.Read src/System/Process/Read.hs:283:3)
2016-07-16 21:19:45.580545: [debug] Getting Cabal package version @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.GhcPkg src/Stack/GhcPkg.hs:165:5)
2016-07-16 21:19:45.580831: [debug] Run process: ghc-pkg --no-user-package-db field --simple-output Cabal version @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:System.Process.Read src/System/Process/Read.hs:283:3)
2016-07-16 21:19:45.634373: [debug] Resolving package entries @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Setup src/Stack/Setup.hs:221:5)
2016-07-16 21:19:45.635603: [debug] Getting global package database location @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.GhcPkg src/Stack/GhcPkg.hs:48:5)
2016-07-16 21:19:45.635844: [debug] Run process: ghc-pkg --no-user-package-db list --global @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:System.Process.Read src/System/Process/Read.hs:283:3)
2016-07-16 21:19:45.708881: [debug] Run process: ghc-pkg --global --no-user-package-db dump --expand-pkgroot @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:System.Process.Read src/System/Process/Read.hs:283:3)
2016-07-16 21:19:45.820616: [debug] Ignoring package haskeline due to wanting version 0.7.2.3 instead of 0.7.2.1 @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
2016-07-16 21:19:45.820961: [debug] Ignoring package terminfo due to wanting version 0.4.0.2 instead of 0.4.0.1 @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
2016-07-16 21:19:45.822500: [debug] Ignoring package Cabal due to wanting version 1.22.8.0 instead of 1.22.5.0 @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Installed src/Stack/Build/Installed.hs:189:5)
2016-07-16 21:19:45.823092: [debug] Run process: ghc-pkg --user --no-user-package-db --package-db /home/username/.stack/snapshots/x86_64-linux/lts-6.7/7.10.3/pkgdb dump --expand-pkgroot @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:System.Process.Read src/System/Process/Read.hs:283:3)
2016-07-16 21:19:45.875934: [debug] Run process: ghc-pkg --user --no-user-package-db --package-db /home/username/stack-directory-problem/.stack-work/install/x86_64-linux/lts-6.7/7.10.3/pkgdb dump --expand-pkgroot @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:System.Process.Read src/System/Process/Read.hs:283:3)
2016-07-16 21:19:45.950677: [debug] Getting global package database location @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.GhcPkg src/Stack/GhcPkg.hs:48:5)
2016-07-16 21:19:45.950927: [debug] Run process: ghc-pkg --no-user-package-db list --global @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:System.Process.Read src/System/Process/Read.hs:283:3)
2016-07-16 21:19:46.007935: [info] stack-directory-problem-0.1.0.0: build @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Execute src/Stack/Build/Execute.hs:731:23)
2016-07-16 21:19:46.008256: [debug] Run process: /home/username/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.5.0 build lib:stack-directory-problem exe:stack-directory-problem-exe --ghc-options " -ddump-hi -ddump-to-file" @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:System.Process.Read src/System/Process/Read.hs:283:3)
2016-07-16 21:19:46.074006: [info] Preprocessing library stack-directory-problem-0.1.0.0... @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Execute src/Stack/Build/Execute.hs:911:67)
2016-07-16 21:19:46.955604: [info] In-place registering stack-directory-problem-0.1.0.0... @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Execute src/Stack/Build/Execute.hs:911:67)
2016-07-16 21:19:46.956223: [info] Preprocessing executable 'stack-directory-problem-exe' for @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Execute src/Stack/Build/Execute.hs:911:67)
2016-07-16 21:19:46.956408: [info] stack-directory-problem-0.1.0.0... @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Execute src/Stack/Build/Execute.hs:911:67)
2016-07-16 21:19:47.077586: [warn]  @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Execute src/Stack/Build/Execute.hs:911:67)
2016-07-16 21:19:47.078541: [warn] /home/username/stack-directory-problem/app/Main.hs:4:8: @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Execute src/Stack/Build/Execute.hs:911:67)
2016-07-16 21:19:47.078916: [warn]     Could not find module ‘System.Directory’ @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Execute src/Stack/Build/Execute.hs:911:67)
2016-07-16 21:19:47.079229: [warn]     It is a member of the hidden package ‘directory-1.2.2.0@direc_0hFG6ZxK1nk4zsyOqbNHfm’. @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Execute src/Stack/Build/Execute.hs:911:67)
2016-07-16 21:19:47.079537: [warn]     Perhaps you need to add ‘directory’ to the build-depends in your .cabal file. @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Execute src/Stack/Build/Execute.hs:911:67)
2016-07-16 21:19:47.079985: [warn]     Use -v to see a list of the files searched for. @(stack-1.1.2-E7j2u8dvJq15OGUl9w7aBF:Stack.Build.Execute src/Stack/Build/Execute.hs:911:67)

--  While building package stack-directory-problem-0.1.0.0 using:
      /home/username/.stack/setup-exe-cache/x86_64-linux/setup-Simple-Cabal-1.22.5.0-ghc-7.10.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-1.22.5.0 build lib:stack-directory-problem exe:stack-directory-problem-exe --ghc-options " -ddump-hi -ddump-to-file"
    Process exited with code: ExitFailure 1
@sjakobi
Copy link
Member

sjakobi commented Jul 16, 2016

Could it be that you forgot to add directory to the build-depends of the executable section?

@23ua
Copy link
Author

23ua commented Jul 16, 2016

You're right. My bad.
Thank you for the answer and sorry for the noise.

@23ua 23ua closed this as completed Jul 16, 2016
@sjakobi
Copy link
Member

sjakobi commented Jul 17, 2016

No worries! :)

Let me use this occasion to plug https://github.com/sol/hpack, an alternative, Cabal-compatible package metadata format, where you can define common dependencies that will apply to all the package sections. This reduces the amount of editing that you have to do to add a dependency and helps you avoid simple mistakes like this one! :)

@prrraveen
Copy link

Why do we need to add package manually to build-depends? shouldn't it be added when installing package by stack install directory.

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

3 participants