commercialhaskell / stack-ide

Stack-based JSON interface to ide-backend
98 stars 23 forks source link

stack-mode not working in Emacs #44

Closed thomasjm closed 9 years ago

thomasjm commented 9 years ago

I installed all the packages (stack-ide, ide-backend, etc.) and added the haskell-mode-hook for stack-mode. When I open a Haskell file for my project and run stack-mode-start, and then navigate around/reload the file a few times, I get output like this:

Starting: ("stack:hite" nil "stack" "ide" "start" "hite")
<- {"tag":"ResponseWelcome","contents":[0,1,1]}
<- {"tag":"ResponseUpdateSession","contents":{"tag":"UpdateStatusRequiredRestart","contents":[]}}
<- {"tag":"ResponseUpdateSession","contents":{"tag":"UpdateStatusProgress","contents":{"progressOrigMsg":"[1 of 1] Compiling Paths_hite       ( /Users/tomm/hite/.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/autogen/Paths_hite.hs, interpreted )","progressStep":1,"progressNumSteps":1,"progressParsedMsg":"Compiling Paths_hite"}}}
<- {"tag":"ResponseUpdateSession","contents":{"tag":"UpdateStatusDone","contents":[]}}
-> {"tag":"RequestGetSourceErrors","contents":[]}
<- {"tag":"ResponseGetSourceErrors","contents":[]}
-> {"tag":"RequestUpdateSession","contents":[]}
<- {"tag":"ResponseUpdateSession","contents":{"tag":"UpdateStatusDone","contents":[]}}
-> {"tag":"RequestGetSourceErrors","contents":[]}
<- {"tag":"ResponseGetSourceErrors","contents":[]}
...

No matter what I do, no Flycheck underlines appear in my buffer.

As far as I can tell, the only thing that is happening is stack-mode sending some RequestGetSourceErrors and ide-backend responding that there aren't any. I've introduced several blatant errors into my code though.

On a possibly related note, doing C-c C-l (stack-mode-load) doesn't work the way I expect based on similar functions like haskell-process-load-or-reload. As far as I can tell it just results in the following exchange with ide-backend:

-> {"tag":"RequestUpdateSession","contents":[]}
<- {"tag":"ResponseUpdateSession","contents":{"tag":"UpdateStatusDone","contents":[]}}
-> {"tag":"RequestGetSourceErrors","contents":[]}
<- {"tag":"ResponseGetSourceErrors","contents":[]}

but it doesn't result in the symbols from my buffer getting loaded or being available from the ghci prompt. Shouldn't stack-mode-load cause my normal inferior Haskell ghci process to load the current buffer?

Note that I tried this with the Emacs config in the emacs-haskell-config repo as well, and got the same results. Is my ide-backend just misbehaving?

Thanks in advance for any help!

cies commented 9 years ago

It seems rather similar to the issues I had (integrating stack-ide into sublimetext), described in this issue:

https://github.com/lukexi/stack-ide-sublime/issues/2

There are some pointers in that thread, like that the cabal file name needs to be the same as the underlying directory name. I'm not sure if that's also the case for you.

thomasjm commented 9 years ago

Thanks @cies -- I think I might have something of the sort going on, but it seems more like a problem that happens while the emacs plugin is starting up.

In emacs, if I evaluate the function (stack-mode-packages) in my buffer, I get this output:

("stack: <stdin>: Data.ByteString.hGetLine: end of file" "{\"tag\":\"ResponseWelcome\",\"contents\":[0,1,1]}" "{\"tag\":\"ResponseUpdateSession\",\"contents\":{\"tag\":\"UpdateStatusRequiredRestart\",\"contents\":[]}}" "{\"tag\":\"ResponseUpdateSession\",\"contents\":{\"tag\":\"UpdateStatusDone\",\"contents\":[]}}" "{\"tag\":\"ResponseFatalError\",\"contents\":\"user error (not enough input)\"}")

And the following gets printed to the Messages buffer:

This cabal project “hite” isn't in your stack.yaml configuration.

This seems pretty clearly wrong. I'm not sure how (shell-command-to-string "stack ide packages") on stack-mode.el:485 is supposed to work anyway, since typing stack ide packages at the terminal results in the stack IDE backend starting up exactly the same as stack ide start does. Is stack ide packages either a deprecated command or a bleeding-edge new one? I've pulled and installed the latest stack-ide (as well as ide-backend etc.) so I'm pretty confused here.

bixuanzju commented 9 years ago

Can you try to use this version of stack

$  stack --version
Version 0.1.2.7, Git revision 68e194622b3c52be3d386b2e9b807ec1ac288828

and try it on one of my projects

$ stack ide packages
fcore

gives me exactly the same project name as in .cabal config file.

thomasjm commented 9 years ago

Okay, I installed the latest master branch of stack and got a little further. Now stack ide packages works properly and my Messages buffer doesn't show the error anymore, but instead says [1/1] Compiling Paths_hite.

I think something's still wrong, because I should see all the different modules in my project being compiled, right? Instead all I get is something starting with Paths_:

...
<- {"tag":"ResponseLog","contents":"[Info] Found ide-backend-server - using this one: /Users/tomm/.local/bin/ide-backend-server @(ideba_HqZKAqZV4wa5sqhSD7XjZv:IdeSession.RPC.Client ./IdeSession/RPC/Client.hs:343:5)\n"}
<- {"tag":"ResponseLog","contents":"[Debug] Recompile required, starting... @(ideba_HqZKAqZV4wa5sqhSD7XjZv:IdeSession.Update.ExecuteSessionUpdate ./IdeSession/Update/ExecuteSessionUpdate.hs:223:5)\n"}
<- {"tag":"ResponseUpdateSession","contents":{"tag":"UpdateStatusProgress","contents":{"progressOrigMsg":"[1 of 1] Compiling Paths_hite       ( /Users/tomm/hite/.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/build/autogen/Paths_hite.hs, interpreted )","progressStep":1,"progressNumSteps":1,"progressParsedMsg":"Compiling Paths_hite"}}}
<- {"tag":"ResponseUpdateSession","contents":{"tag":"UpdateStatusDone","contents":[]}}
-> {"tag":"RequestGetSourceErrors","contents":[]}
<- {"tag":"ResponseGetSourceErrors","contents":[]}
thomasjm commented 9 years ago

I'm going to close this issue and re-open a new one now that it's clear this is more of a stack-ide / ide-backend issue than an Emacs one