Closed BillyBadBoy closed 8 years ago
Could you open dev. console (View → Developer → Toggle Developer Tools) and look for warnings? I have a creeping suspicion Atom fails to find stack executable.
console excerpt:
haskell-ghc-mod warning: No compiler found, expected minor version match with ghc-7.10.3 (x86_64) (based on resolver setting in /home/william/fib/stack.yaml).
Try running "stack setup" to install the correct GHC into /home/william/.stack/programs/x86_64-linux/
/home/william/.atom/packages/haskell-ghc-mod/lib/util.coffee:63 haskell-ghc-mod warning: Running stack path,--snapshot-install-root,--local-install-root failed with Error: Command failed: stack path --snapshot-install-root --local-install-root(…)
/home/william/.atom/packages/haskell-ghc-mod/lib/util.coffee:63 haskell-ghc-mod warning: No stack sandbox found because Error: Command failed: stack path --snapshot-install-root --local-install-root(…)
/home/william/.atom/packages/haskell-ghc-mod/lib/util.coffee:56 haskell-ghc-mod debug: PATH = function resolve() { [native code] }:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/go/bin
/home/william/.atom/packages/haskell-ghc-mod/lib/util.coffee:56 haskell-ghc-mod debug: Running ghc-mod version with opts = Object
/home/william/.atom/packages/haskell-ghc-mod/lib/util.coffee:63 haskell-ghc-mod warning: Running ghc-mod version failed with Error: spawn ghc-mod ENOENT(…)
BTW if I run atom via stack exec atom
then everything works fine.
more info:
from atom console:
process.env.PATH
"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/go/bin"
$ which stack
$ /usr/bin/stack
Okay, quick sanity check then. Check you stack version, and whether command stack path --snapshot-install-root --local-install-root
produces meaningful output.
stack version = 1.1.2
Where should I run the stack path command from ? project directory? home directory ?
Project directory
$ stack path --snapshot-install-root --local-install-root
snapshot-install-root: /home/william/.stack/snapshots/x86_64-linux/lts-6.6/7.10.3
local-install-root: /home/william/myProj/.stack-work/install/x86_64-linux/lts-6.6/7.10.3
Huh. Okay. I think I figured out what the problem is. Do you happen to have 'Cabal Sandbox' option disabled? If so, then try updating haskell-ghc-mod to 1.15.1, it should probably work.
That didn't help.
But I've noticed something strange. I'm using linux mint and normally start atom by clicking on a launch applet on my desktop. This launcher seems to be the problem. If I launch atom from a terminal (from any directory) then ghc-mod is OK.
This is really strange. Do you happen to have some stack- or PATH-related setup in your .bashrc
/.zshrc
?
You're right - my .bashrc
file contains entries I used to rely on in my pre-stack days:
export PATH="$HOME/.cabal/bin:/opt/cabal/1.22/bin:/opt/ghc/7.10.3/bin:$PATH"
If I comment this out then ghc-mod is broken regardless of how I launch atom.
Try running stack setup
in your project directory.
I tried removing the globally installed ghc and this causes atom to break from both my launcher and the command line. So it's the global ghc that somehow allows ghc-mod to work when I launch from the command line.
With the global ghc removed I ran stack setup which caused a local ghc to be installed. Atom ghc-mod still broken - but failing with completely different error messages.
I'm rebuilding local ghc-mod to see if this makes a difference.
It now works!!!
ghc
completely (but see below)ghc-mod
.bashrc
+ .profile
After doing this it still did not work. The error was not atom related since I could reproduce it from the command line:
~/myProj $ stack exec ghc-mod check /home/william/myProj/src/Lib.hs
ghc-mod: /opt/ghc/7.10.3/lib/ghc-7.10.3/settings: openFile: does not exist (No such file or directory)
For some reason ghc-mod was trying to access a file from the deleted global ghc installation. I was unable to figure out where the invalid path was being stored, so in desperation I tried removing and then re-installing the stack executable (followed by stack setup
), which seems to have fixed everything.
So, the end result is that haskell-ghc-mod
now works on my machine but at the cost of having to remove my global ghc
installation.
Thanks for all your help.
Since my original problem is now fixed I'm closing this issue.
I have a simple project created using stack but ghc-mod is not being found. Info:
stack new myProj
stack build ghc-mod