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

haskell-ghc-mod doesn't support local GHC using Stack #44

Closed elldritch closed 8 years ago

elldritch commented 9 years ago

I'm creating a project using Stack that uses a different GHC version from $(which ghc). This causes

Haskell-ghc-mod: ~/.cabal/bin/ghc-mod check ~/project/File.hs failed with error code 1
cabal: At least the following dependencies are missing:
base >=4.7 && <5
ghc-mod: readProcess: cabal "configure" "--with-ghc=ghc" (exit 1): failed

because my local GHC doesn't support base >=4.7 && <5 but the one I'm stack building with does. Is there a way to configure haskell-ghc-mod to recognise and use GHCs on stack path when possible?

lierdakil commented 9 years ago

You could play with additionalPathDirectories setting, which prepends those to PATH before running ghc-mod. That said, Stack support in ghc-mod is limited at best, see https://github.com/kazu-yamamoto/ghc-mod/issues/498

DanielG commented 9 years ago

That totally a bug in ghc-mod. Honestly I forgot we were using the executables in cabal-helper ;)

See https://github.com/kazu-yamamoto/ghc-mod/issues/564

wolftune commented 9 years ago

That issue was fixed. And ghc-mod works with stack now, but I haven't got it working in Atom yet… Note that newer update to ghc-mod is available, but this Atom package still says "Supported ghc-mod versions are from 4.1.0 to 5.2.1.2." — is that enforced or just outdated docs?

lierdakil commented 9 years ago

That's not enforced, but 5.3.0.0 isn't supported officially (although it works most of the time, it sometimes doesn't, and I can't do much about that here). If there was another release, I've missed it, and will update docs accordingly after testing. 7 сент. 2015 г. 11:29 пользователь "Aaron Wolf" notifications@github.com написал:

That issue was fixed. And ghc-mod works with stack now, but I haven't got it working in Atom yet… Note that newer update to ghc-mod is available, but this Atom package still says "Supported ghc-mod versions are from 4.1.0 to 5.2.1.2." — is that enforced or just outdated docs?

— Reply to this email directly or view it on GitHub https://github.com/atom-haskell/haskell-ghc-mod/issues/44#issuecomment-138232928 .

wolftune commented 9 years ago

The latest git version of ghc-mod is required for supporting Stack right now. The next full hackage release will include those fixes. So, for this to fully work, we will need both that update to ghc-mod and for this to work with it.

I tested with the latest git ghc-mod and running Atom did make ghc-mod do a lot of CPU work, but I didn't successfully get any useful results in Atom.

lierdakil commented 9 years ago

Look, current development branch is obviously not supported officially, since I have no control over ghc-mod repo. To be frank, I don't have time to hotfix all compatibility issues before actual release, it's that simple. When it does release, I will rush to get it working. Until release, everything in ghc-mod is subject to sudden change. If you're desperate, PRs are always welcome. Sorry, but I just can't help here.

2015-09-07 20:31 GMT+03:00 Aaron Wolf notifications@github.com:

The latest git version of ghc-mod is required for supporting Stack right now. The next full hackage release will include those fixes. So, for this to fully work, we will need both that update to ghc-mod and for this to work with it.

I tested with the latest git ghc-mod and running Atom did make ghc-mod do a lot of CPU work, but I didn't successfully get any useful results in Atom.

— Reply to this email directly or view it on GitHub https://github.com/atom-haskell/haskell-ghc-mod/issues/44#issuecomment-138346345 .

wolftune commented 9 years ago

I wasn't asking you to do anything right now, I was clarifying for the ticket's reference sake what the status is. And I did want to know for reference whether there was a coded block about versions versus just being in the docs. Thanks

DanielG commented 9 years ago

@lierdakil the next release is probably going out soon so you should catch up before that happens ;)

lierdakil commented 9 years ago

Okay, I've tested current HEAD at the moment (ce1d9d1), and it works with Atom pretty much like it should. Didn't try with stack though. @wolftune, could you check if it works with cabal projects for you? If not, could you enable 'Debug' option in haskell-ghc-mod settings and post dev. console output?

wolftune commented 9 years ago

holy moly, it worked! @DanielG as soon as this ghc-mod update is released to hackage, I think it will work to even try installing with Stack, and this should generally then be all set, this ticket will be done!

I must say, as much as this works, it's pretty slow and resource-intense, but maybe pretty usable on a more powerful computer.

DanielG commented 9 years ago

@wolftune make sure you're using this (https://github.com/kazu-yamamoto/ghc-mod/commit/64379a7c56f4e1d6efa44439ec9be8e644b43faa) commit it fixes reloads being super slow.

wolftune commented 9 years ago

@DanielG I did have that already, and yes, I would not describe it as "super slow" just as "quite slow". It's like laggy and such. I wish I had some better indication of the process and wish it was really quite fast, but it's definitely better than "super slow".

lierdakil commented 9 years ago

Type/info queries are expected to be slowish the first time around, but if you're using ghc-modi backend, then subsequent queries should be relatively fast. On really big projects it can still take a second or two though, according to my experience.

Check and lint are not meant to be fast (I.e. I use non-interactive interface for those, as it's more robust, although can be considerably slower), so those can take a little while.

Not sure if I can do much about it on my end. 11 сент. 2015 г. 11:52 пользователь "Aaron Wolf" notifications@github.com написал:

@DanielG https://github.com/DanielG I did have that already, and yes, I would not describe it as "super slow" just as "quite slow". It's like laggy and such. I wish I had some better indication of the process and wish it was really quite fast, but it's definitely better than "super slow".

— Reply to this email directly or view it on GitHub https://github.com/atom-haskell/haskell-ghc-mod/issues/44#issuecomment-139491253 .

xavier83 commented 9 years ago

@lierdakil I tested it too and as you said Type/Info queries on non stack projects worked like you described(like 1-2 seconds), but I agree with @wolftune 's description of the stack projects problem, it is definitely "quite slow" as in 10 seconds now, as compared to 30 seconds "super slow" - before https://github.com/kazu-yamamoto/ghc-mod/commit/64379a7c56f4e1d6efa44439ec9be8e644b43faa landed.

http://lpaste.net/140696

denisshevchenko commented 8 years ago

How can I use haskell-ghc-mod in stack-based project? I haven't cabal-install, and in this case ghc-mod must have parameter --with-stack with path to stack. Without that parameter I got an error:

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

So in Settings of haskell-ghc-mod package should be the input for specify of path to stack.

wolftune commented 8 years ago

@denisshevchenko

That's it.

denisshevchenko commented 8 years ago

Sorry, it doesn't work. I have this version ghc-mod:

$ ghc-mod --version
ghc-mod version 5.4.0.0 compiled by GHC 7.10.2

And I've added full path to ghc-mod and ghc-modi in Packages -> Haskell Ghc Mod -> Ghc Mod Path and Packages -> Haskell Ghc Mod -> Ghc Modi Path. But after that I got this error again:

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

As I understand, ghc-mod cannot work with Stack without --with-stack parameter. But I can't find this parameter in haskell-ghc-mod package...

denisshevchenko commented 8 years ago

And yes, I know about this caveat:

  there is one caveat though if `dist/setup-config` exists in a Cabal-project directory ghc-mod will continue
  using cabal-install instead of Stack so if you want to use Stack instead simply remove that file or the whole directory. You also need at least Stack version 0.1.4.0 for this to work."

I haven't dist directory in my project, and this is my stack version:

$ stack --version
Version 0.1.4.1

So?

denisshevchenko commented 8 years ago

Ok, It works now. Thanks.

wolftune commented 8 years ago

Looks like this can be closed

thunky-monk commented 8 years ago

@denisshevchenko Would you mind sharing how you got it to work?

When in a non-global project I get the same error you had:

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

In Atom in the global project, it works. Also, it works from command line in all projects.

WillSewell commented 8 years ago

I also get the same error. Would love to know how you got it working.

ruslantalpa commented 8 years ago

@WillSewell @hamsterdam delete "dist/" directory from the root of your project

WillSewell commented 8 years ago

@ruslantalpa I did that, but every time I used ghc-mod check from within atom, it would be recreated. I solved the issue by using the version of ghc in the global stack directory on my system.

eatobin commented 8 years ago

I get the same Atom error after following all advice above. 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)

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

Thanks.