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

Cannot use "getDirectoryConents" function in stack project on Windows 10. I can in Stack ghci #2135

Closed
ahgibbons opened this issue May 13, 2016 · 6 comments
Milestone

Comments

@ahgibbons
Copy link

I'm having a problem listing the files in a directory on Windows 10. I am using the getDirectoryContents function located in the System.Directory (directory) package. When building the program Stack tries to install the time package and fails. The suggestion is to add MinGW+MSYS to the toolchain. However, when I use stack ghci I am able to use the getDirectoryContents function. Is there a reason why I cannot use the same function when building a program?

Steps to Reproduce:

  1. Create new stack project with stack new getFiles
  2. Add directory to the build-depends of the getFiles.cabal file.
  3. Use the following code for Main.hs
module Main where

import Lib
import System.Directory
import System.Environment


main :: IO ()
main = do
  args <- getArgs
  let indir = head args
  files <- getDirectoryContents indir
  print files
  1. Run stack build.

Expected:
I expected the program to compile.

Actual:
The program did not compile. Here is my error message:

PS C:\andrew\Haskell\timedebug> stack build
time-1.5.0.1: configure
Progress: 1/3
--  While building package time-1.5.0.1 using:
      C:\Users\andrew\AppData\Local\Temp\stack9168\time-1.5.0.1\.stack-work\dist\2672c1f3\setup\setup --builddir=.stack-work\dist\2672c1f3 configure --with-ghc=C:\Users\andrew\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\bin\ghc.exe --with-ghc-pkg=C:\Users\andrew\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\bin\ghc-pkg.exe --user --package-db=clear --package-db=global --package-db=C:\stack_root\snapshots\5fb55b82\pkgdb --libdir=C:\stack_root\snapshots\5fb55b82\lib --bindir=C:\stack_root\snapshots\5fb55b82\bin --datadir=C:\stack_root\snapshots\5fb55b82\share --libexecdir=C:\stack_root\snapshots\5fb55b82\libexec --sysconfdir=C:\stack_root\snapshots\5fb55b82\etc --docdir=C:\stack_root\snapshots\5fb55b82\doc\time-1.5.0.1 --htmldir=C:\stack_root\snapshots\5fb55b82\doc\time-1.5.0.1 --haddockdir=C:\stack_root\snapshots\5fb55b82\doc\time-1.5.0.1 --dependency=Win32=Win32-2.3.1.1-39aa18a188563287440e1fb568cb2ff0 --dependency=base=base-4.8.2.0-14035a44a8b95c6832da6dae1420f59e --dependency=deepseq=deepseq-1.4.1.1-2c33acf73357f514df72284dd4549b44
    Process exited with code: ExitFailure 1
    Logs have been written to: C:\Users\andrew\Dropbox\Haskell\timedebug\.stack-work\logs\time-1.5.0.1.log

    [1 of 1] Compiling Main             ( C:\Users\andrew\AppData\Local\Temp\stack9168\time-1.5.0.1\Setup.hs, C:\Users\andrew\AppData\Local\Temp\stack9168\time-1.5.0.1\.stack-work\dist\2672c1f3\setup\Main.o )
    Linking C:\Users\andrew\AppData\Local\Temp\stack9168\time-1.5.0.1\.stack-work\dist\2672c1f3\setup\setup.exe ...
    Configuring time-1.5.0.1...
    setup.exe: The package has a './configure' script. This requires a Unix
    compatibility toolchain such as MinGW+MSYS or Cygwin.

My stack version is:

Version 1.1.1, Git revision 990fbb1aec2f0badeaefe30788ac9309dc179f22 x86_64 hpack-0.14.0

Here is the output of stack build --verbose:

PS C:\Users\andrew\Dropbox\Haskell\timedebug> stack build
time-1.5.0.1: configure
Progress: 1/3
--  While building package time-1.5.0.1 using:
      C:\Users\andrew\AppData\Local\Temp\stack9168\time-1.5.0.1\.stack-work\dist\2672c1f3\setup\setup --builddir=.stack-work\dist\2672c1f3 configure --with-ghc=C:\Users\andrew\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\bin\ghc.exe --with-ghc-pkg=C:\Users\andrew\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\bin\ghc-pkg.exe --user --package-db=clear --package-db=global --package-db=C:\stack_root\snapshots\5fb55b82\pkgdb --libdir=C:\stack_root\snapshots\5fb55b82\lib --bindir=C:\stack_root\snapshots\5fb55b82\bin --datadir=C:\stack_root\snapshots\5fb55b82\share --libexecdir=C:\stack_root\snapshots\5fb55b82\libexec --sysconfdir=C:\stack_root\snapshots\5fb55b82\etc --docdir=C:\stack_root\snapshots\5fb55b82\doc\time-1.5.0.1 --htmldir=C:\stack_root\snapshots\5fb55b82\doc\time-1.5.0.1 --haddockdir=C:\stack_root\snapshots\5fb55b82\doc\time-1.5.0.1 --dependency=Win32=Win32-2.3.1.1-39aa18a188563287440e1fb568cb2ff0 --dependency=base=base-4.8.2.0-14035a44a8b95c6832da6dae1420f59e --dependency=deepseq=deepseq-1.4.1.1-2c33acf73357f514df72284dd4549b44
    Process exited with code: ExitFailure 1
    Logs have been written to: C:\Users\andrew\Dropbox\Haskell\timedebug\.stack-work\logs\time-1.5.0.1.log

    [1 of 1] Compiling Main             ( C:\Users\andrew\AppData\Local\Temp\stack9168\time-1.5.0.1\Setup.hs, C:\Users\andrew\AppData\Local\Temp\stack9168\time-1.5.0.1\.stack-work\dist\2672c1f3\setup\Main.o )
    Linking C:\Users\andrew\AppData\Local\Temp\stack9168\time-1.5.0.1\.stack-work\dist\2672c1f3\setup\setup.exe ...
    Configuring time-1.5.0.1...
    setup.exe: The package has a './configure' script. This requires a Unix
    compatibility toolchain such as MinGW+MSYS or Cygwin.
PS C:\Users\andrew\Dropbox\Haskell\timedebug> stack build --verbose
Version 1.0.5, Git revision 57eb614df50826f38b923e1892cda904288a8ec9 x86_64 hpack-0.12.0
2016-05-13 12:05:02.713483: [debug] Checking for project config at: C:\Users\andrew\Dropbox\Haskell\timedebug\stack.yaml @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.Config src/Stack\Config.hs:779:9)
2016-05-13 12:05:02.715484: [debug] Loading project config file stack.yaml @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.Config src/Stack\Config.hs:797:13)
2016-05-13 12:05:02.724490: [debug] Trying to decode C:\stack_root\build-plan-cache\x86_64-windows\lts-5.16.cache @(stack_6z1PPTeQ1JiHDL7m2t2akP:Data.Binary.VersionTagged src/Data\Binary\VersionTagged.hs:55:5)
2016-05-13 12:05:02.766519: [debug] Success decoding C:\stack_root\build-plan-cache\x86_64-windows\lts-5.16.cache @(stack_6z1PPTeQ1JiHDL7m2t2akP:Data.Binary.VersionTagged src/Data\Binary\VersionTagged.hs:64:13)
2016-05-13 12:05:02.767519: [debug] Getting system compiler version @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.Setup src/Stack\Setup.hs:341:17)
2016-05-13 12:05:02.793539: [debug] Run process: ghc --info @(stack_6z1PPTeQ1JiHDL7m2t2akP:System.Process.Read src/System\Process\Read.hs:283:3)
2016-05-13 12:05:02.909613: [debug] Asking GHC for its version @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.Setup.Installed src/Stack\Setup\Installed.hs:91:13)
2016-05-13 12:05:02.910614: [debug] Run process: ghc --numeric-version @(stack_6z1PPTeQ1JiHDL7m2t2akP:System.Process.Read src/System\Process\Read.hs:283:3)
2016-05-13 12:05:02.974656: [debug] Getting Cabal package version @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.GhcPkg src/Stack\GhcPkg.hs:165:5)
2016-05-13 12:05:02.975658: [debug] Run process: ghc-pkg --no-user-package-db field --simple-output Cabal version @(stack_6z1PPTeQ1JiHDL7m2t2akP:System.Process.Read src/System\Process\Read.hs:283:3)
2016-05-13 12:05:03.147771: [debug] Resolving package entries @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.Setup src/Stack\Setup.hs:221:5)
2016-05-13 12:05:03.150774: [debug] Getting global package database location @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.GhcPkg src/Stack\GhcPkg.hs:48:5)
2016-05-13 12:05:03.152775: [debug] Run process: ghc-pkg --no-user-package-db list --global @(stack_6z1PPTeQ1JiHDL7m2t2akP:System.Process.Read src/System\Process\Read.hs:283:3)
2016-05-13 12:05:03.329892: [debug] Checking resolver: lts-5.16 @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.Build.Source src/Stack\Build\Source.hs:159:17)
2016-05-13 12:05:03.330893: [debug] Trying to decode C:\stack_root\build-plan-cache\x86_64-windows\lts-5.16.cache @(stack_6z1PPTeQ1JiHDL7m2t2akP:Data.Binary.VersionTagged src/Data\Binary\VersionTagged.hs:55:5)
2016-05-13 12:05:03.380928: [debug] Success decoding C:\stack_root\build-plan-cache\x86_64-windows\lts-5.16.cache @(stack_6z1PPTeQ1JiHDL7m2t2akP:Data.Binary.VersionTagged src/Data\Binary\VersionTagged.hs:64:13)
2016-05-13 12:05:03.404942: [debug] Run process: ghc-pkg --global --no-user-package-db dump --expand-pkgroot @(stack_6z1PPTeQ1JiHDL7m2t2akP:System.Process.Read src/System\Process\Read.hs:283:3)
2016-05-13 12:05:03.646102: [debug] Ignoring package Win32 due to wanting version 2.3.1.1 instead of 2.3.1.0 @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.Build.Installed src/Stack\Build\Installed.hs:189:5)
2016-05-13 12:05:03.647102: [debug] Ignoring package haskeline due to wanting version 0.7.2.3 instead of 0.7.2.1 @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.Build.Installed src/Stack\Build\Installed.hs:189:5)
2016-05-13 12:05:03.649104: [debug] Ignoring package Cabal due to wanting version 1.22.8.0 instead of 1.22.5.0 @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.Build.Installed src/Stack\Build\Installed.hs:189:5)
2016-05-13 12:05:03.652108: [debug] Run process: ghc-pkg --user --no-user-package-db --package-db C:\stack_root\snapshots\5fb55b82\pkgdb dump --expand-pkgroot @(stack_6z1PPTeQ1JiHDL7m2t2akP:System.Process.Read src/System\Process\Read.hs:283:3)
2016-05-13 12:05:03.825220: [debug] Run process: ghc-pkg --user --no-user-package-db --package-db C:\Users\andrew\Dropbox\Haskell\timedebug\.stack-work\install\0a2b75f2\pkgdb dump --expand-pkgroot @(stack_6z1PPTeQ1JiHDL7m2t2akP:System.Process.Read src/System\Process\Read.hs:283:3)
2016-05-13 12:05:03.999336: [debug] Trying to decode C:\stack_root\indices\Hackage\00-index.cache @(stack_6z1PPTeQ1JiHDL7m2t2akP:Data.Binary.VersionTagged src/Data\Binary\VersionTagged.hs:55:5)
2016-05-13 12:05:04.478658: [debug] Success decoding C:\stack_root\indices\Hackage\00-index.cache @(stack_6z1PPTeQ1JiHDL7m2t2akP:Data.Binary.VersionTagged src/Data\Binary\VersionTagged.hs:64:13)
2016-05-13 12:05:04.775851: [debug] Getting global package database location @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.GhcPkg src/Stack\GhcPkg.hs:48:5)
2016-05-13 12:05:04.776856: [debug] Run process: ghc-pkg --no-user-package-db list --global @(stack_6z1PPTeQ1JiHDL7m2t2akP:System.Process.Read src/System\Process\Read.hs:283:3)
2016-05-13 12:05:05.270180: [info] time-1.5.0.1: configure @(stack_6z1PPTeQ1JiHDL7m2t2akP:Stack.Build.Execute src/Stack\Build\Execute.hs:731:23)
2016-05-13 12:05:05.324215: [debug] Run process: C:\Users\andrew\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\bin\ghc.exe --make -odir C:\Users\andrew\AppData\Local\Temp\stack7216\time-1.5.0.1\.stack-work\dist\2672c1f3\setup -hidir C:\Users\andrew\AppData\Local\Temp\stack7216\time-1.5.0.1\.stack-work\dist\2672c1f3\setup -i -i. -package=Cabal-1.22.5.0 -clear-package-db -global-package-db -package-db=C:\stack_root\snapshots\5fb55b82\pkgdb C:\Users\andrew\AppData\Local\Temp\stack7216\time-1.5.0.1\Setup.hs -o C:\Users\andrew\AppData\Local\Temp\stack7216\time-1.5.0.1\.stack-work\dist\2672c1f3\setup\setup @(stack_6z1PPTeQ1JiHDL7m2t2akP:System.Process.Read src/System\Process\Read.hs:301:3)
2016-05-13 12:05:20.238110: [debug] Run process: C:\Users\andrew\AppData\Local\Temp\stack7216\time-1.5.0.1\.stack-work\dist\2672c1f3\setup\setup --builddir=.stack-work\dist\2672c1f3 configure --with-ghc=C:\Users\andrew\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\bin\ghc.exe --with-ghc-pkg=C:\Users\andrew\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\bin\ghc-pkg.exe --user --package-db=clear --package-db=global --package-db=C:\stack_root\snapshots\5fb55b82\pkgdb --libdir=C:\stack_root\snapshots\5fb55b82\lib --bindir=C:\stack_root\snapshots\5fb55b82\bin --datadir=C:\stack_root\snapshots\5fb55b82\share --libexecdir=C:\stack_root\snapshots\5fb55b82\libexec --sysconfdir=C:\stack_root\snapshots\5fb55b82\etc --docdir=C:\stack_root\snapshots\5fb55b82\doc\time-1.5.0.1 --htmldir=C:\stack_root\snapshots\5fb55b82\doc\time-1.5.0.1 --haddockdir=C:\stack_root\snapshots\5fb55b82\doc\time-1.5.0.1 --dependency=Win32=Win32-2.3.1.1-39aa18a188563287440e1fb568cb2ff0 --dependency=base=base-4.8.2.0-14035a44a8b95c6832da6dae1420f59e --dependency=deepseq=deepseq-1.4.1.1-2c33acf73357f514df72284dd4549b44 @(stack_6z1PPTeQ1JiHDL7m2t2akP:System.Process.Read src/System\Process\Read.hs:301:3)
Progress: 1/3
--  While building package time-1.5.0.1 using:
      C:\Users\andrew\AppData\Local\Temp\stack7216\time-1.5.0.1\.stack-work\dist\2672c1f3\setup\setup --builddir=.stack-work\dist\2672c1f3 configure --with-ghc=C:\Users\andrew\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\bin\ghc.exe --with-ghc-pkg=C:\Users\andrew\AppData\Local\Programs\stack\x86_64-windows\ghc-7.10.3\bin\ghc-pkg.exe --user --package-db=clear --package-db=global --package-db=C:\stack_root\snapshots\5fb55b82\pkgdb --libdir=C:\stack_root\snapshots\5fb55b82\lib --bindir=C:\stack_root\snapshots\5fb55b82\bin --datadir=C:\stack_root\snapshots\5fb55b82\share --libexecdir=C:\stack_root\snapshots\5fb55b82\libexec --sysconfdir=C:\stack_root\snapshots\5fb55b82\etc --docdir=C:\stack_root\snapshots\5fb55b82\doc\time-1.5.0.1 --htmldir=C:\stack_root\snapshots\5fb55b82\doc\time-1.5.0.1 --haddockdir=C:\stack_root\snapshots\5fb55b82\doc\time-1.5.0.1 --dependency=Win32=Win32-2.3.1.1-39aa18a188563287440e1fb568cb2ff0 --dependency=base=base-4.8.2.0-14035a44a8b95c6832da6dae1420f59e --dependency=deepseq=deepseq-1.4.1.1-2c33acf73357f514df72284dd4549b44
    Process exited with code: ExitFailure 1
    Logs have been written to: C:\Users\andrew\Dropbox\Haskell\timedebug\.stack-work\logs\time-1.5.0.1.log

    [1 of 1] Compiling Main             ( C:\Users\andrew\AppData\Local\Temp\stack7216\time-1.5.0.1\Setup.hs, C:\Users\andrew\AppData\Local\Temp\stack7216\time-1.5.0.1\.stack-work\dist\2672c1f3\setup\Main.o )
    Linking C:\Users\andrew\AppData\Local\Temp\stack7216\time-1.5.0.1\.stack-work\dist\2672c1f3\setup\setup.exe ...
    Configuring time-1.5.0.1...
    setup.exe: The package has a './configure' script. This requires a Unix
    compatibility toolchain such as MinGW+MSYS or Cygwin.

Running in ghci

  1. Change directory into getFiles directory made above.
  2. Run stack ghci
  3. Load directory functions with System.Directory.
  4. Run function files <- getDirectoryContents '.'
  5. Print the files using print files

The results is the output of the files and folders in the getFiles folder. As expected.

@mgsloan
Copy link
Contributor

mgsloan commented May 13, 2016

stack setup installs this toolchain. Did you install ghc via stack setup, or some other way? You can either uninstall your system ghc or put system-ghc: false in your $STACK_ROOT/config.yaml and run stack setup.

@mgsloan mgsloan added this to the Support milestone May 13, 2016
@ahgibbons
Copy link
Author

Before I first installed stack I uninstalled my previous ghc and then used stack setup, so I assume I don't have any other versions of ghc except those that came with stack.
I will try what you suggest and report back soon.

@ahgibbons
Copy link
Author

Wow, this worked! Thanks, it is installing correctly now.

@mgsloan
Copy link
Contributor

mgsloan commented May 13, 2016

Cool, glad it's working!

@mgsloan mgsloan closed this as completed May 13, 2016
@ahgibbons
Copy link
Author

Is there a disadvantage to having the system-ghc: false setting in the $STACK_ROOT/config.yaml files?

@mgsloan
Copy link
Contributor

mgsloan commented May 13, 2016

@ahgibbons Not really, infact, I think it is worthwile revisiting that default - #1901

It makes it a little bit harder to use custom ghc installs, and could potentially use up more diskspace if you already have a ghc install. That's the only downside AFAICT. It would certainly save me the effort of asking about ghc installation method :)

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