Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

ghc-mod + stack: Emacs hanging opening Haskell file #575

Closed
bixuanzju opened this issue Aug 29, 2015 · 18 comments
Closed

ghc-mod + stack: Emacs hanging opening Haskell file #575

bixuanzju opened this issue Aug 29, 2015 · 18 comments
Assignees

Comments

@bixuanzju
Copy link

ghc-mod + stack work fine from the command line, but using it inside Emacs hangs Emacs, buffer freezes on "Initialiing ...", and I have to C-g to cancel. Besides, if I use the cabal instead of stack, everything works fine. So I suspect there's something wrong in the elisp code for the stack integration.

I am using Emacs 24.5, both the elisp and binary are compiled from the github repo. I am happy to provide any other information, thanks!

@luigy
Copy link

luigy commented Aug 29, 2015

hey I think I figured it out! stack logging of lockfile warnings messes up what the elisp code expects...
I removed the lockfile logging from stack and it doesn't hang anymore
cc @kazu-yamamoto

with vanilla stack:

....
CONTENTS + EOT
Failed to grab lock ("/Users/luigy/.stack/lockfile"); other stack instance running.  Waiting...
Lock acquired, proceeding.
Failed to grab lock ("/Users/luigy/.stack/lockfile"); other stack instance running.  Waiting...
Lock acquired, proceeding.
E: Failed to grab lock ("/Users/luigy/.stack/lockfile"); other stack instance running.  Waiting...
E: Lock acquired, proceeding.
Failed to grab lock ("/Users/luigy/.stack/lockfile"); other stack instance running.  Waiting...
Lock acquired, proceeding.
O: OK
% boot
% ghc-mod root
........

@bixuanzju
Copy link
Author

@luigy It didn't work in my case. Where did you see that Failed to grab lock ... message?

@luigy
Copy link

luigy commented Aug 29, 2015

add (setq ghc-debug t) to your dotspacemacs/config and make sure you don't have a dist folder around root dir

I'm also using a ghc-mod compiled from dev-stack branch ( I haven't tried it out with master yet) and latest elisp code that spacemacs installs for ghc-mod is fine

you should see a *GHC Debug* buffer after doing a C-g when it hangs on Initializing .... and most likely it should look similar to mine around the beginning

@bixuanzju
Copy link
Author

@luigy Thanks, I can reproduce now. Wonder why there is other stack instance running when using ghc-mod inside Emacs.

@luigy
Copy link

luigy commented Aug 29, 2015

@bixuanzju should be related to commercialhaskell/stack#872 ... stack path is called a few times in dev-stack to get different paths
get rid of that logging and stack support looks good so far

@DanielG
Copy link
Owner

DanielG commented Aug 29, 2015

Which branch are you guys even using? Anyways the lockfile logging stuff was fixed in stack master some time ago and I got a bunch of other stuff we needed merged, should go into stack-1.4, or so I've been told. Will be working on stack support again this Monday so just hang on for a while ;)

@luigy
Copy link

luigy commented Aug 29, 2015

@DanielG nice! feels so good to have "stackReconfigure" back with stack + ghc-mod... working good so far 🙌 Haven't ran into any problems yet ;)

The lockfile warnings keep happening to me on stack master, though

@bixuanzju
Copy link
Author

@DanielG I am always using the master branch, but lockfile problem still persists.

@DanielG
Copy link
Owner

DanielG commented Sep 2, 2015

@bixuanzju You're using stack from master too?

@bixuanzju
Copy link
Author

@DanielG yes, everything from master

@DanielG
Copy link
Owner

DanielG commented Sep 2, 2015

Well you'll have to figure out where the other stack process(es) are coming from then since I can't reproduce this. It might have to do with ghc-mod legacy-interactive forking off a thread to build the find symbol table on startup. That has caused a race condition with cabal-helper before so it's not impossible that this is causing trouble again.

@ajnsit
Copy link

ajnsit commented Sep 3, 2015

Can confirm. I had to modify the stack code to remove the code that prints the locking error message, and the problem got resolved!

@PierreR
Copy link
Contributor

PierreR commented Sep 5, 2015

I can confirm this as well. By adding 2>/dev/null as mentioned in #454 I still get the message Failed to grab lock a couple of times (even with stack-1.4 version) but no more infinite loops.

As an aside, I have to use the ghc-mod binary generated by cabal in .cabal-sandbox. If I try to use one generated by stack install (in ~/.local/bin/), it hangs forever as well.

@bixuanzju
Copy link
Author

@DanielG FYI, I am still having the same problem in the master branch

@DanielG
Copy link
Owner

DanielG commented Sep 8, 2015

That's all nice and well but without more information or a way to reproduce this I can't really do anything about it >_>

@kazu-yamamoto kazu-yamamoto self-assigned this Sep 9, 2015
@kazu-yamamoto
Copy link
Collaborator

Now Daniel and I can reproduce this. Daniel is working on this.

@bixuanzju
Copy link
Author

@DanielG awesome! The HEAD fixed my problem, finally I can embrace ghc-mod with stack!

@kazu-yamamoto
Copy link
Collaborator

This has been fixed on master.

mineo added a commit to mineo/dotfiles that referenced this issue Sep 24, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants