Closed lippling closed 8 years ago
same for me. I usually hack around this issue by creating a top level package '.' whose aim is only to import all libs from all other local packages. This way atom ghc-mod picks all libraries from local packages.
@rvion Do you have an example?
@lippling this is not a proper example, but something like that: https://github.com/rvion/ghcid-bug-repro
note that this workaround doesn't load the code for executable tagets unless you load those file in ghc-mod. if you want ghc-mod to be aware of everything, you have to put all your executable code in dedicated libraries, all of them exposing some libMain, and have single module executables like that
module Executable where
import Lib
main = libMain
then, your top level '.' package need to depends on all libraries including those wrapping executable code.
this workaround is far from ideal, but works quite okay.
as a side note, even with this technique, ghc-mod + stack doesn't play well with ghci / ghcid. so there is still a few problems to solve :/ if you have ghcid running along ide-haskell, ghc-mod will crash, and ide-haskell will stop working. (I don't this issue has been reported yet, but it is reproductible on various setup :/)
Thanks! I'll give it a try.
I think this issue belongs on ghc-mod repo https://github.com/DanielG/ghc-mod/issues Not sure I can do anything on this end. /cc @DanielG
I've managed to track down this issue to a bug in an isDirectory function of atom-haskell-utils module.
The line at the following URL seems to work unreliably: https://github.com/atom-haskell/atom-haskell-utils/blob/fc01220c2afc4379181afbd631b70777d1d215c1/src/util.coffee#L8
It says
when (dir instanceof Directory) or (dir instanceof File)
making use of JavaScript instanceof
operator. I'm by no means an expert in JavaScript, but debugging clearly shows that for some directories this expression returns false
despite console dump tells that dir
is an instance of Directory.
This means that getRootDir
function from the same module always takes getRootDirFallback
route and uses atom project root (and not the directory where .cabal
is located) as a startup directory for ghc-mod
.
I've replaced that line with
when (dir.getPath)
and it fixed the problem for me.
Okay then... instanceof
fails miserably between frames, but I assumed it should be fine in Atom. Apparently not. Oh well. I switched to duck typing, so let's now hope for the best.
It works for me now with ghc-mod-5.5.0.0 :)
This should hopefully be resolved to a somewhat satisfactory degree. If not, please open new issues.
I've the following setup:
stack
withlts-5.13
ghc-mod-5.5.0.0
installed viastack --resolver lts-5.13 build ghc-mod
stack.yaml:
When I open and save a
.hs
file in Atom, every package (which was installed bystack
) is marked with "...could not be found..." after theimport
. This seems only to be the case for multi project setups. When I runatom .
directly in the subdirectory it works.I tested several things (none worked):
~/.ghc-mod
~/.stack
.stack-work
Using
ghc-mod-5.4.0.0
seems to be a workaround:ghc-mod*
which was installed withstack --resolver lts-5.13 build ghc-mod
(~/.stack/snapshots/x86_64-osx/lts-5.13/7.10.3/bin/
).stack --resolver lts-4.2 install ghc-mod
. This installsghc-mod 5.4.0.0
into the~/.local/bin
folder.