haskell / haskell-mode

Emacs mode for Haskell
http://haskell.github.io/haskell-mode/
GNU General Public License v3.0
1.33k stars 342 forks source link

stack-ghci still uses cabal #753

Open drewr opened 9 years ago

drewr commented 9 years ago

stack-ghci doesn't work for me. haskell-session seems to always get to haskell-session-new-assume-from-cabal:

Debugger entered--Lisp error: (quit)
  signal(quit nil)
  y-or-n-p("Start a new project named “craft”? ")
  haskell-session-new-assume-from-cabal()
  (or (haskell-session-from-buffer) (haskell-session-new-assume-from-cabal) (haskell-session-choose) (haskell-session-new))
  (haskell-session-assign (or (haskell-session-from-buffer) (haskell-session-new-assume-from-cabal) (haskell-session-choose) (haskell-session-new)))
  (or (haskell-session-maybe) (haskell-session-assign (or (haskell-session-from-buffer) (haskell-session-new-assume-from-cabal) (haskell-session-choose) (haskell-session-new))))
  haskell-session()
  haskell-process-load-file()
  haskell-process-load-or-reload(nil)
  call-interactively(haskell-process-load-or-reload nil nil)
  command-execute(haskell-process-load-or-reload)

Even though:

haskell-process-type is a variable defined in `haskell-customize.el'.
Its value is stack-ghci
Original value was auto
GNU Emacs 24.5.2 (x86_64-apple-darwin13.4.0) of 2015-06-01

Is there something else I need to do?

geraldus commented 9 years ago

@johnwalker does it really work for you?

johnwalker commented 9 years ago

Works for me, but this setup should also work. Does emacs see stack on your path?

johnwalker commented 9 years ago

Oh, that shouldn't be related. All that is happening is stack ghci is being called in your target directory.

https://github.com/haskell/haskell-mode/blob/4c3cdfdebd5653013e39b220d096158034b35b9e/haskell-process.el#L108

johnwalker commented 9 years ago

What does ps -x tell you about the programs being run?

28042 pts/3    Ssl+   0:01 /home/john/.cabal/bin/stack ghci --ghc-options=-ferror-spans
28065 pts/3    Sl+    0:00 /home/john/.stack/programs/x86_64-linux/ghc-7.8.4/lib/ghc-7.8.4/bin/ghc -B/home/john/.stack/programs/x86_64-linux/ghc-7.
28290 pts/5    R+     0:00 ps -x
drewr commented 9 years ago

Interesting, ps indeed shows stack ghci was spawned. Any ideas why I still get the cabal dialog? Any way to turn it off?

johnwalker commented 9 years ago

I think the fault is in:

  (let ((target (haskell-session-target session)))
    (if target (list target) nil))
johnwalker commented 9 years ago

Instead of this chunk of code, we should just prompt for a directory to run stack ghci.

johnwalker commented 9 years ago

Oh no, that seems fine. Still thinking. But it's definitely a problem with the elisp

johnwalker commented 9 years ago

OK, I think I know whats going on. If you do ps -aux | grep cabal, it should give you a huge line with stack and then buried off to the side a reference to the version of cabal that stack is using. This should be the only instance of cabal used for interaction.

For example

28886  home/john/.stack/programs/x86_64-linux/ghc-7.8.4/lib/ghc-7.8.4/bin/ghc -B/home/john/.stack/programs/x86_64-linux/ghc-7.8.4/lib/ghc-7.8.4 --interactive -hide-all-packages -i/home/john/z/scr/ -i/home/john/z/scr/src/ -i/home/john/z/scr/.stack-work/dist/x86_64-linux/Cabal-1.18.1.5/build/autogen/ -optP-include -optP/home/john/z/scr/.stack-work/dist/x86_64-linux/Cabal-1.18.1.5/build/autogen/cabal_macros.h -package=base -package=text -package=bytestring -package=HTTP -package=http-conduit -package=tagsoup -rtsopts -with-rtsopts=-N -i/home/john/z/scr/app/ -package=scr -i/home/john/z/scr/test/ /home/john/z/scr/src/Lib.hs -ferror-spans

Can you tell me more about the cabal dialog you're getting? Is it a prompt from emacs?

drewr commented 9 years ago

It's the flow that goes:

Start a new project named.... ?
Cabal dir:
build target (empty for default):
Set current directory:

I hadn't updated my haskell-mode in a while, so this may just be new behavior. I'd like to just have a GHCI prompt from C-c C-l but it wasn't obvious from the elisp how to do it.

johnwalker commented 9 years ago

I can see how that is confusing. We should probably mention to the user whether stack or cabal is being used in the line that begins "Start a new project named ... ? "

gracjan commented 9 years ago

@drewr @johnwalker: Did you manage to resolve what is going on here?

I would love to merge a pull request that improves messages around cabal/stack startup as we seem to have many confused users here.

johnwalker commented 9 years ago

Yes. I don't know how much of this process is needed:

Start a new project named.... ?
Cabal dir:
build target (empty for default):
Set current directory:

And what is confusing users is the line "cabal dir."

johnwalker commented 9 years ago

Do we need a call to haskell-session-target?

https://github.com/haskell/haskell-mode/blob/4c3cdfdebd5653013e39b220d096158034b35b9e/haskell-process.el#L116

gracjan commented 9 years ago

@johnwalker: Can you do one thing for me and change this:

Start a new project named.... ?
Cabal dir:
build target (empty for default):
Set current directory:

Into this:

Start a new $type project named.... ?
Directory where project *.cabal file is located (empty to autodetect):
Project build target (empty for default):
Set current directory to (empty for default):

and put $type over there to ghci to cabal-repl or stack-ghci.

(Note that cabal-ghci should no longer exist. I do not remember why is it still there.)

ivan-m commented 9 years ago

Whilst the wording can be improved, I think your suggestions @gracjan are a tad too long, the 2nd one in particular.

Maybe something like:

Project root directory (empty to autodetect):

I also wonder whether the last prompt is needed with cabal-repl as you specify the directories used in the .cabal file...

gracjan commented 9 years ago

Whole workflow needs improvement, meanwhile I'd like to have it mouthful.

johnwalker commented 9 years ago

Yes, I'll do this late on Wednesday.

johnwalker commented 9 years ago

Will take me a little longer

gracjan commented 9 years ago

That is ok. We will wait.

PierreR commented 9 years ago

:+1: I have just been bitten by this one ;-) Will revert to use an external ghci session.