atom-haskell / ide-haskell

Haskell IDE plugin for Atom editor
https://atom.io/packages/ide-haskell
Other
233 stars 30 forks source link

TemplateHaskell breaks IDE features #146

Closed japgolly closed 7 years ago

japgolly commented 8 years ago

Using

{-# LANGUAGE TemplateHaskell   #-}

causes the IDE to report 0 errors and 0 warnings, and prevents type inspections from working, even for other files in the project.

lierdakil commented 8 years ago

Try building it. Most likely, you have some sort of problem with your TH. In any case, TH works fine for me, so this is not universal.

japgolly commented 8 years ago

Hello. The code builds fine; it's not a compilation problem. Literally just a blank file with that pragma causes the problem for me. On 25 Mar 2016 11:37, "Nikolay Yakimov" notifications@github.com wrote:

Try building it. Most likely, you have some sort of problem with your TH. In any case, TH works fine for me, so this is not universal.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/atom-haskell/ide-haskell/issues/146#issuecomment-201085720

lierdakil commented 8 years ago

Okay. Some sanity checks first. Could you tell me your

?

Also, is it cabal, stack or plain project?

Lastly, does running ghc-mod directly from terminal work? F.ex. given this Haskell source in Main.hs

{-# LANGUAGE TemplateHaskell #-}

main :: IO ()

(yes, it is a signature without an accompanying binding)

what is output of

ghc-mod check Main.hs

?

japgolly commented 8 years ago

I'm out of town for a few days but I'll tell you what I can remember now.

Ghc is 7.10.3 Ghc-mod is 5.5.0.0 Atom is 1.6.0 with all packages updated. OS is Arch Linux 64bit, kernel 4.4.1. Project is stack-based.

I'll get back you with the rest when I get back home next week.

japgolly commented 8 years ago

I'm getting this on my laptop too so I can trying ghc-mod check:

> ghc-mod check src/Lib.hs
unable to load package `text-1.2.2.0'

Aha! So there's a CLI problem but the atom plugin didn't present it. Ok, let's try....

> cabal install text      
Resolving dependencies...
All the requested packages are already installed:
text-1.2.2.1
Use --reinstall if you want to reinstall anyway.

Hmmm....

> cabal install text-1.2.2.0
Resolving dependencies...
Downloading text-1.2.2.0...
Configuring text-1.2.2.0...
Building text-1.2.2.0...
Installed text-1.2.2.0

> ghc-mod check src/Lib.hs  
unable to load package `text-1.2.2.0'

Erm. Now what? (FYI I'm a Haskell noob so apologies if there's something obvious I'm missing here.)

lierdakil commented 8 years ago

Oh my... Your system is kinda borked I fear. Welcome to cabal hell. Run ghc-pkg check to see what exactly goes wrong (you can safely ignore haddock warnings). Ways to fix this usually include wiping ~/.cabal and ~/.ghc and starting over, preferably using sandboxes.

japgolly commented 8 years ago

Cabal hell indeed. I wiped my ~/.{cabal,ghc,ghc-mod,stack} directories and installed everything from scratch multiple times. Same error.

And that was on my laptop. Now that I'm back home, I tried it again on my desktop where I originally saw the error and guess what?

> ghc-mod check src/Lib.hs
ghc-mod: /home/golly/haskell/.stack/snapshots/x86_64-linux/lts-5.10/7.10.3/lib/x86_64-linux-ghc-7.10.3/cryptonite-0.10-9z0j8QI27Av2VIWw0mEkTO/libHScryptonite-0.10-9z0j8QI27Av2VIWw0mEkTO.a: unhandled ELF relocation(RelA) type 42

unable to load package `cryptonite-0.10'

:tired_face:

So I dutifully wiped my ~/.{cabal,ghc,ghc-mod,stack} directories and installed everything from scratch again. Same cryptonite error.

Why does it all have to be so hard? How is everyone else installing this stuff? After wiping, I'm just doing:

cabal update
cabal install happy && cabal install haskell-src-exts
cabal install ghc-mod pointfree pointful hlint stylish-haskell hdevtools dash-haskell
lierdakil commented 8 years ago

Okay, now it looks like you're mixing cabal-install and stack, which is usually a bad idea unless you know exactly what you're doing.

If you're working on stack project, easy solution: go to project folder, do stack install ghc-mod. Make sure you have 'stack sandbox' enabled, no 'Additional Path Directories' and default value for 'path to ghc-mod'. This will install ghc-mod locally into your project directory, and all should be well (assuming everything installs, which it should -- but at this point, I'm not convinced)

If you're working on cabal project, it gets a little bit more convoluted, but long story short, sandbox everything (i.e. do cabal sandbox init for every project and install tooling into sandbox). It usually works.

Why this happens: GHC is very picky about library versions. And ghc-mod is, simply put, a thick wrapper over core GHC library. So when something differs between environments in which you built ghc-mod and a project you're running it on, it can lead to all kinds of unexpected results.

Sorry I can't be of more help.

japgolly commented 8 years ago

Thank you for the advice! You filled me with hope and so I wiped my ~/.{cabal,ghc,ghc-mod,stack} dirs again and this time didn't touch cabal but instead ran stack install ghc-mod. It was nice to see it install properly without needing me to manually install happy and haskell-src-exts first.

Once it was done I ran stack exec ghc-mod check src/Lib.hs and got:

ghc-mod: /home/golly/haskell/.stack/snapshots/x86_64-linux/lts-5.10/7.10.3/lib/x86_64-linux-ghc-7.10.3/cryptonite-0.10-9z0j8QI27Av2VIWw0mEkTO/libHScryptonite-0.10-9z0j8QI27Av2VIWw0mEkTO.a: unhandled ELF relocation(RelA) type 42

unable to load package `cryptonite-0.10'

:sob:

It's got to be the same as this: https://github.com/DanielG/ghc-mod/issues/762 In which case, should we close this?

lierdakil commented 7 years ago

Okay, since this is basically a GHC bug https://ghc.haskell.org/trac/ghc/ticket/12147, there's no real reason to keep this open. Sorry I can't offer a workaround.