Haskell-ide-engine: Erroneous import highlights in ST3

Created on 25 Jan 2018  路  10Comments  路  Source: haskell/haskell-ide-engine

Modules imported from packages listed in "build-depends" section of the cabal file are highlighted as "Could not find module", even if they are installed globally and stack build works. Also, all modules in my project have the similar highlight.

How do I circumvent this problem?

Config: Ubuntu16.04, stack-1.6.3, latest hie, latest ST3

linux sublime

Most helpful comment

Can a ST3 user make a PR against the README about this?

All 10 comments

I have the same problem.

@jflanglois There are two possible solutions, both are based on the same effect: ST3 normally inherits PATH from where it was launched (and, therefore, so does hie). Packages outside base are visible from stack path, but not from PATH, hence the can't find module.

First solution - launch ST3 via stack: stack exec -- sublime .
Second solution - lauch hie from ST3 via stack: in the LSP config the command should be "command": ["/path/to/stack", "exec", "--", "hie-wrapper", "--lsp", "-d"]

@ShrykeWindgrace Ah I just realized that I misread the issue. In my case only internal imports from the package are not working for hie. But thank you for your response!

Can a ST3 user make a PR against the README about this?

@alanz I can do that, but not earlier than tomorrow morning

@ShrykeWindgrace both proposed solutions seem wrong to me, as stack exec needs to use the correct resolver for the project

@nponeccop and why would it not use the correct one? If I launch ST3 in my project folder via stack exec -- sublime ., stack knows about the resolver, doesn't it?

It does, but the workaround defeats both purposes of hie-wrapper namely:

  • to detect the project root
  • to detect the resolver and GHC version

See #439 for details. So this is essentially an issue with hie-wrapper, not a documentation issue. Of course a workaround could be documented as a temporary workaround.

@nponeccop even if hie-wrapper manages to detect the project root, resolver, and ghc version, how does it spawn the corresponding hie? Does it supply the correct path (via stack exec / stack path / its cabal counterpart)? If it does not, then the problem of finding locally installed executables like hspec-discover (or simply packages only visible to stack path) remains.

I agree that both my solutions are closer to workarounds than to longterm approaches, but these are the only solutions I found so far.

I agree. The workaround is worth documenting, and the issue with hie is worth fixing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alanz picture alanz  路  3Comments

awave1 picture awave1  路  4Comments

xgrommx picture xgrommx  路  4Comments

ghost picture ghost  路  4Comments

JorisBlanken picture JorisBlanken  路  4Comments