Ford O.
Ford O.

Reputation: 1498

Intero : Failed to load interface for Lib

I am trying to setup my Haskero (Visual Studio Code extension that uses Intero) for my Haskell project, yet I get the following error :

app\Main.hs:3:1: error:
   Failed to load interface for `Lib'
   Use -v to see a list of the files searched for.

Steps to reproduce:

stack new project
cd project
stack build intero
stack exec intero
> :l app/Main.hs

app/Main.hs :

module Main where

import Lib

main :: IO ()
main = someFunc

src/Lib.hs :

module Lib
   ( someFunc
   ) where

someFunc :: IO ()
someFunc = putStrLn "someFunc"

Upvotes: 4

Views: 1296

Answers (2)

Adam Szlachta
Adam Szlachta

Reputation: 121

I had similar issue occuring in Visual Studio Code.

Under the hood Haskero properly uses:

stack ghci --with-ghc intero --no-build --no-load

However Haskero assumes that the stack project is the working directory loaded to VSCode. If instead the stack project is one of the subdirectories then the same error appears in IDE, because stack command is run from that main directory. At least it's what happens currently with Haskero 1.3.1.

The solution is to always make sure that stack project is equal to working directory in VSCode.

Upvotes: 2

K. A. Buhr
K. A. Buhr

Reputation: 51029

I don't have experience with Haskero but can duplicate the problem with a plain old Intero installation on a Linux machine.

The issue is that you're invoking the Intero backend via stack exec instead of stack ghci. You would observe the same problem if you tried using stack exec ghci instead of stack ghci to invoke a usual GHC interactive session (see the documentation for stack ghci for more information).

Instead of stack exec intero, try:

stack ghci --with-ghc intero --no-build --no-load

and it should work okay.

(Note that stack exec intero actually works okay if you stack build your project first, but the interactive session is still supposed to be invoked via stack ghci.)

Upvotes: 1

Related Questions