Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

TemplateHaskell breaks IDE features #146

Closed
japgolly opened this issue Mar 23, 2016 · 10 comments
Closed

TemplateHaskell breaks IDE features #146

japgolly opened this issue Mar 23, 2016 · 10 comments

Comments

@japgolly
Copy link

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
Copy link
Contributor

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
Copy link
Author

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
#146 (comment)

@lierdakil
Copy link
Contributor

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

  • GHC version
  • ghc-mod version
  • Atom version
  • OS

?

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
Copy link
Author

japgolly commented Mar 25, 2016 via email

@japgolly
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

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'

😫

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
Copy link
Contributor

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
Copy link
Author

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'

😭

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

@lierdakil
Copy link
Contributor

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.

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

2 participants