atom-haskell-archive / haskell-ghc-mod

haskell-ghc-mod atom package
https://atom.io/packages/haskell-ghc-mod
MIT License
69 stars 20 forks source link

ghc-mod fails in cabal project #58

Closed zmactep closed 8 years ago

zmactep commented 8 years ago

Everything works fine when I edit some non-project hs file, but each time I press Cmd-S, when cabal project is added as a root directory, I see an error popup with this text:

cabal-helper-wrapper: ghc: readCreateProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
ghc-mod: readCreateProcess: /Users/pavel/.cabal/libexec/cabal-helper-wrapper "--with-ghc=ghc" "--with-ghc-pkg=ghc-pkg" "--with-cabal=cabal" "/Users/pavel/Documents/DEV/biocad/tests/ysar" "/Users/pavel/Documents/DEV/biocad/tests/ysar/dist" "package-db-stack" "entrypoints" "source-dirs" "ghc-options" "ghc-src-options" "ghc-pkg-options" "ghc-merged-pkg-options" "ghc-lang-options" "licenses" (exit 1): failed

OS X 10.10.5 Atom 1.0.19 Cabal 1.22.6.0 (from Homebrew) ghc 7.10.2 (from Homebrew) ghc-mod 5.4.0.0 (from cabal)

lierdakil commented 8 years ago

Looks like ghc-mod can't find cabal-helper-wrapper. It should be in .cabal/libexec/. If you don't have /Users/pavel/.cabal/libexec/cabal-helper-wrapper, this might indicate an installation issue. Otherwise if it's there, I'm not sure what's going on.

zmactep commented 8 years ago

I have it and it works, as I can see. From console%

$ /Users/pavel/.cabal/libexec/cabal-helper-wrapper "--with-ghc=ghc" "--with-ghc-pkg=ghc-pkg" "--with-cabal=cabal" "/Users/pavel/Documents/DEV/biocad/tests/ysar" "/Users/pavel/Documents/DEV/biocad/tests/ysar/dist" "package-db-stack" "entrypoints" "source-dirs" "ghc-options" "ghc-src-options" "ghc-pkg-options" "ghc-merged-pkg-options" "ghc-lang-options" "licenses"
WARNING: cache is out of date: /usr/local/Cellar/ghc/7.10.2/lib/ghc-7.10.2/package.conf.d/package.cache
ghc will see an old view of this package db. Use 'ghc-pkg recache' to fix.
[1 of 5] Compiling CabalHelper.Types ( CabalHelper/Types.hs, /Users/pavel/.ghc-mod/cabal-helper/CabalHelper/Types.o )
[2 of 5] Compiling CabalHelper.Common ( CabalHelper/Common.hs, /Users/pavel/.ghc-mod/cabal-helper/CabalHelper/Common.o )
[3 of 5] Compiling CabalHelper.Sandbox ( CabalHelper/Sandbox.hs, /Users/pavel/.ghc-mod/cabal-helper/CabalHelper/Sandbox.o )
[4 of 5] Compiling CabalHelper.Licenses ( CabalHelper/Licenses.hs, /Users/pavel/.ghc-mod/cabal-helper/CabalHelper/Licenses.o )
[5 of 5] Compiling Main             ( CabalHelper/Main.hs, /Users/pavel/.ghc-mod/cabal-helper/Main.o )
Linking /Users/pavel/.ghc-mod/cabal-helper/cabal-helper-0.6.0.0-Cabal-1.22.4.0 ...
[Just (ChResponsePkgDbs [ChPkgGlobal,ChPkgUser]),Just (ChResponseEntrypoints [(ChLibName,ChLibEntrypoint {chExposedModules = [ChModuleName "Data.YSAR"], chOtherModules = []}),(ChExeName "ysar",ChExeEntrypoint {chMainIs = "Main.hs", chOtherModules = []}),(ChSetupHsName,ChSetupEntrypoint)]),Just (ChResponseCompList [(ChLibName,["src"]),(ChExeName "ysar",["bin"]),(ChSetupHsName,[])]),Just (ChResponseCompList [(ChLibName,["-fbuilding-cabal-package","-O","-outputdir","dist/build","-odir","dist/build","-hidir","dist/build","-stubdir","dist/build","-i","-idist/build","-isrc","-idist/build/autogen","-Idist/build/autogen","-Idist/build","-optP-include","-optPdist/build/autogen/cabal_macros.h","-hide-all-packages","-package-id","base-4.8.1.0-075aa0db10075facc5aaa59a7991ca2f","-XHaskell2010"]),(ChExeName "ysar",["-fbuilding-cabal-package","-O","-outputdir","dist/build","-odir","dist/build","-hidir","dist/build","-stubdir","dist/build","-i","-idist/build/ysar/ysar-tmp","-ibin","-idist/build","-isrc","-idist/build/autogen","-Idist/build/ysar/ysar-tmp","-Idist/build/autogen","-Idist/build","-optP-include","-optPdist/build/autogen/cabal_macros.h","-hide-all-packages","-package-id","base-4.8.1.0-075aa0db10075facc5aaa59a7991ca2f","-XHaskell2010"]),(ChSetupHsName,[])]),Just (ChResponseCompList [(ChLibName,["-i","-idist/build","-isrc","-idist/build/autogen","-Idist/build/autogen","-Idist/build","-optP-include","-optPdist/build/autogen/cabal_macros.h"]),(ChExeName "ysar",["-i","-idist/build/ysar/ysar-tmp","-ibin","-idist/build/autogen","-Idist/build/autogen","-Idist/build/ysar/ysar-tmp","-optP-include","-optPdist/build/autogen/cabal_macros.h"]),(ChSetupHsName,[])]),Just (ChResponseCompList [(ChLibName,["-hide-all-packages","-package-id","base-4.8.1.0-075aa0db10075facc5aaa59a7991ca2f"]),(ChExeName "ysar",["-fbuilding-cabal-package","-O","-outputdir","dist/build","-odir","dist/build","-hidir","dist/build","-stubdir","dist/build","-i","-idist/build","-isrc","-idist/build/autogen","-Idist/build/autogen","-Idist/build","-optP-include","-optPdist/build/autogen/cabal_macros.h","-hide-all-packages","-package-id","base-4.8.1.0-075aa0db10075facc5aaa59a7991ca2f","-XHaskell2010"]),(ChSetupHsName,[])]),Just (ChResponseList ["-fbuilding-cabal-package","-O","-outputdir","dist/build","-odir","dist/build","-hidir","dist/build","-stubdir","dist/build","-i","-idist/build","-isrc","-idist/build/autogen","-Idist/build/autogen","-Idist/build","-optP-include","-optPdist/build/autogen/cabal_macros.h","-hide-all-packages","-package-id","base-4.8.1.0-075aa0db10075facc5aaa59a7991ca2f","-XHaskell2010"]),Just (ChResponseCompList [(ChLibName,["-XHaskell2010"]),(ChExeName "ysar",["-XHaskell2010"]),(ChSetupHsName,[])]),Just (ChResponseLicenses [("BSD3",[("integer-gmp",Version {versionBranch = [1,0,0,0], versionTags = []}),("ghc-prim",Version {versionBranch = [0,4,0,0], versionTags = []}),("rts",Version {versionBranch = [1,0], versionTags = []}),("base",Version {versionBranch = [4,8,1,0], versionTags = []})])])]
CanLikeTo commented 8 years ago

I get the exact same behaviour when I've built from the command line first. When I Cmd-S with no dist directory, I just get the following:

ghc-mod: cabal: readCreateProcess: runInteractiveProcess: exec: does not exist (No such file or directory)

@zmactep Have you found a solution by any chance?

eatobin commented 8 years ago

I have a similar issue using Stack and I've added a comment under Issue #44.

"Haskell-ghc-mod: /home/eric/.local/bin/ghc-mod check /home/eric/code/my-project/src/Main.hs failed with error code 1 ghc-mod: cabal: readCreateProcess: runInteractiveProcess: exec: does not exist (No such file or directory)"

I get the same Atom error after following all advice above (from Issue #44). ghc-mod check works fine from command line for both Stack/non-Stack located .hs files and also works inside Atom for non-Stack located .hs files. But trying to check (cmd-s) a Stack located .hs file in Atom gives me the above error.

$ which ghc-mod = /home/eric/.local/bin/ghc-mod (set to same in Haskell-ghc-mod) $ which ghc = /home/eric/.stack/programs/i386-linux/ghc-7.10.2/bin/ghc extra-deps: [ghc-mod-5.4.0.0] in project stack.yaml no dist folder in project root directory (but .stack-work/dist exists) have: /home/eric/.stack/global-project/.stack-work/install/i386-linux/lts-3.15/7.10.2/libexec/cabal-helper-wrapper

Stumped. How do I ghc-mod check files interactively within Atom and within a Stack project.

Thanks.

lierdakil commented 8 years ago

@eatobin, here's a crazy idea: run Atom from terminal, with, in project directory, stack exec atom. This whole thing seems very much like an environment issue, and this trick might help solving that, at least until we figure out what is going wrong exactly.

Please make sure to delete dist/ directory first, as ghc-mod tends to get confused sometimes and tries to cabal configure a stack project.

eatobin commented 8 years ago

fib_tuple.txt

Thank you! Tried it and no crashes! But... check this out: Save the attached file to src in a stack project and also to Desktop. The file when opened in the stack project directory with "stack exec atom" opens and returns no Errors and no Warnings. Now open this same file from the Desktop (don't close Atom) and there are no Errors and 2 Warnings on line 9??!!

Do you get similar results?

lierdakil commented 8 years ago

Would you mind telling what are those warnings specifically? I'm on Linux and don't use stack, so testing this would be a problem.

lierdakil commented 8 years ago

Ah, nevermind that. Unused variables I presume?

lierdakil commented 8 years ago

Try adding {-# OPTIONS_GHC -Wall #-} pragma to your source file. Maybe cabal/stack settings suppress some warnings.

eatobin commented 8 years ago

The pragma did it - that was it. Thank you!

lierdakil commented 8 years ago

Would you mind posting output of stack exec env for future reference?

eatobin commented 8 years ago

stack-exec-env.txt

Sure.