Running emacs intero-mode with stack docker integration - haskell

I'm trying to use intero-mode in a stack project that has the docker integration enabled. Therefore its stack.yml contains:
docker:
enable: true
image: my-project/build:lts-11.9
Even though, when I open any .hs file in the project, intero-mode tries to install the intero executable and fails. In the Messages buffer it reports:
Installed successfully! Starting Intero in a moment ...
Booting up intero ...
Problem with Intero!
Reading Haskell configuration failed with exit code 1 and output:
get-cabal-configuration.hs: /home/jesuspc/.nix-profile/bin/hpack: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
And I get the error screen for intero-mode:
...
The process ended. Here is the reason that Emacs gives us:
exited abnormally with code 1
For troubleshooting purposes, here are the arguments used to launch intero:
stack ghci --with-ghc /home/jesuspc/.stack/compiler-tools/x86_64-linux-dke094d5208e8a802cb369cecdad3049ae/ghc-8.2.2/bin/intero "--docker-run-args=--interactive=true --tty=false" --no-build --no-load --ghci-options -ignore-dot-ghci my-project
...
When I run that line I get:
Did not find executable at specified path: /home/jesuspc/.stack/compiler-tools/x86_64-linux-dke094d5208e8a802cb369cecdad3049ae/ghc-8.2.2/bin/intero
Which may be something related to nix, because I found that by running instead:
stack ghci --with-ghc /home/jesuspc/.stack/compiler-tools/x86_64-linux-nix/ghc-8.2.2/bin/intero "--docker-run-args=--interactive=true --tty=false" --no-build --no-load --ghci-options -ignore-dot-ghci my-project
I get a different error:
/home/jesuspc/.stack/compiler-tools/x86_64-linux-nix/ghc-8.2.2/bin/intero: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
I believe that this error may be thrown because my project uses external libraries and it can not find them, but that's just a guess.
Is intero-mode even aware of the stack-docker integration? It seems to be trying to use the intero executable in my local machine instead of using the docker context, where all the required libraries are present. How can I fix it?

I just came across this issue yesterday as well. It looks like the issue is in the function intero-copy-compiler-tool-auto-install
which does not take into account your stack.yaml file and so does not build intero into the docker container. A super hacky work around I found is to run
stack --docker build --copy-compiler-tool intero
from within your project.

Related

Unable to compile first Haskell Programme in VSCode

I just installed Stack GHCI and Visual Studio Code in my Windows. And I was trying to build and run the first simple Haskell putStrln programme, but with a big compile fail.
In VS Code terminal, I entered:
PS C:\Users\rmili\Documents> stack new TryHaskell
And a new folder "TryHaskell" was created, with the automatically created files "Lib.hs" and "Main.hs"
I tried to build and run the hs files. But I encountered the following errors:
In a new terminal, after I entered PS C:\Users\rmili\Documents\TryHaskell> stack build, this will result in the following error:
Error Messages:
"'C:\Users\rmili\AppData\Local\Programs\stack\x86_64-windows\ghc-8.8.4\bin\ghc-pkg.exe'
exited with an error:
ghc-pkg.exe: hLock: permission denied (Access is denied.)
)"
At the top of Main.hs and Lib.hs, the lines module Main where and module Lib both have curly lines underneath, with error message:
readCreateProcess: stack "exec" "ghc" "--" "-rtsopts=ignore" "-outputdir" "C:\\Users\\rmili\\AppData\\Local\\Temp\\hie-bios-98c9848bfed41b00" "-o" "C:\\Users\\rmili\\AppData\\Local\\hie-bios\\wrapper-4da94d68375fab32d2147da1837e9611.exe" "C:\\Users\\rmili\\AppData\\Local\\hie-bios\\wrapper-4da94d68375fab32d2147da1837e9611.hs" (exit 1): failedcompiler
Peek Problem (Alt+F8)
No quick fixes available
My GHCI directory looks fine, as shown below:
UPDATE: It seemed that antivirus is the problem for me, as whenever I tried to build a new hs file, there will be a pop up from Norton, saying data protector has blocked an action by Haskell server. After I asked Norton to exclude specifically such action, I could successfully compile and run my hs files.
However, the problem is that the curly lines under "module Main where" and "module Lib" remain. How can I remove the curly lines and its associated error messages as shown in point 2) above?
Welcome to Haskell!
Unfortunately, it seems Haskell on Windows has various "permission denied" bugs. (https://gitlab.haskell.org/ghc/ghc/-/issues/2924). I have no direct workaround to suggest, other than make sure all software is up-to-date, try different configurations, and try and build using ghc directly without stack.
Other things to try include making sure you are running as Administrator, and disabling your antivirus.

I cant import System.Directory when using stack

I am little confused about why this doesn't work.
I have a small program that import System.Directory. When I run it with runhaskell on the command line it compiles and outputs what I expect.
When I use the same program with stack I get a message saying
Failed to load interface for ‘System.Directory’
It is a member of the hidden package ‘directory-1.3.0.0’.
Use -v to see a list of the files searched for.
I dont understand why it would work with runhaskell but not when i use stack ghci
With the information you give, I can only attempt a guess…
I think you have directory (globally) installed with cabal install directory or as a system package - this would explain runhaskell myscript.hs working.
if you use stack you have the following options.
make a cabal package, add directory to the build depends section, create a stack.yaml and run stack ghci inside the project directory.
use stack ghci --package=directory myscript.hs

Permission denied when installing ghc using stack setup

I'm following http://seanhess.github.io/2015/08/04/practical-haskell-getting-started.html to get started with the stack tool.
$> stack --version
Version 0.1.3.1, Git revision 908b04205e6f436d4a5f420b1c6c646ed2b804d7
In the step "Installing GHC" I get Permission denied:
$> stack setup
Run from outside a project, using implicit global config
Using resolver: lts-3.2 from global config file: /Users/karl/.stack/global/stack.yaml
Preparing to download ghc-7.10.2 .../Users/karl/.stack/programs/x86_64-osx/ghc-7.10.2.tar.bz2.tmp:
openBinaryFile: permission denied (Permission denied)
Is this expected (a bug in the guide) or a bug in stack?
Running the same command with sudo seems to solve the problem. Is this the intended method?
$> sudo stack setup
Password:
Downloaded ghc-7.10.2.
Installed GHC.
stack will use a locally installed GHC
For more information on paths, see 'stack path' and 'stack exec env'
To use this GHC and packages outside of a project, consider using:
stack ghc, stack ghci, stack runghc, or stack exec
I'm running a fresh install of OS X 10.10.4 (Yosemite).
Thanks to the suggestion by #user5402 I found, that for some reason, ~/.stack/programs was owned by root.
After removing the .stack directory stack setup worked as expected.

Synastic errors - Vim, Stack, Haskell development

I am using stack for my Haskell development and Syntastic for my error checking when editing in Vim. I have not installed the haskell-platform, instead, I use a stack build --install-ghc to get my environment up and running using the supported GHC, cabal and lts packages.
Normally, I use a cabal sandbox and syntastic works well with this. I see when I do a let g:syntastic_debug=3 in Vim, syntastic runs a cabal configure which checks if the project dependencies are installed and then goes ahead and does some hlint, hdevtools and ghc-mod magic to give me some warnings and/or error messages.
Now, here is my problem. Since my cabal setup (installed from stack) doesn't know about my dependencies installed at .stack-work or .stack (not sure), it complains that I am missing necessary packages and blows up when syntastic runs in my Vim instance.
Trying to run a stack exec -- cabal configure returns the following error:
Use of GHC's environment variable GHC_PACKAGE_PATH is incompatible with Cabal. use the flag --package-db to specify a package database (it can be used multiple times).
I haven't found out how to pass the --package-db option with the correct database. Nothing seems to work there.
So, the quetion - will successfully running a stack exec -- cabal configure, avoiding the GHC_PACKAGE_PATH issue get me to a working setup? Can anyone give me some direction here?
hdevtools works. See here: http://seanhess.github.io/2015/08/05/practical-haskell-editors.html
I'm planning on keeping that up to date as new tools come out (like stack-ide).
This blogpost gives a nice introduction as well. Things change quickly in the haskell world and ghc-mod seems to be working well with stack now. The setup from the post requires neovim though.
The setup from the post worked perfectly fine for me and found all dependencies within the current stack project.

IntelliJ publigin: ghc-modi error output: NG quit

I'm just using GHC 7.8.4 and cabal 1.22.0.0 with IntelliJ Haskell plugin. After starting my project, I receive this error log
ghc-modi failed
ghc-modi failed with error: NG BUG: cabal: createProcess: runInteractiveProcess: exec: does not exist (No such file or directory)
You can disable ghc-modi in Settings | Haskell
IOException: Broken pipe
IOException: Broken pipe
How can I solve or get more information on this error?
I had the same problem on Mac OS X and solved it by launching IntelliJ IDEA with open /Applications/IntelliJ\ IDEA\ 14.app shell command.
If you write some scripts for Haskell in .bashrc, it doesn't affect IntelliJ IDEA launched from Desktop or Launchpad e.t.c. Using open shell command let IntelliJ IDEA affected.

Resources