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
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:
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.
Most helpful comment
Can a ST3 user make a PR against the README about this?