commercialhaskell / stack

The Haskell Tool Stack
http://haskellstack.org
BSD 3-Clause "New" or "Revised" License
3.95k stars 842 forks source link

HLS fails due to stack and liquidhaskell #5935

Open 89oinotna opened 1 year ago

89oinotna commented 1 year ago

General summary/comments

HLS does not work if using stack and liquid haskell, if i switch to cabal it works.

Steps to reproduce

vscode 1.73.0 with Haskell plugin configured to use ghcup MacOS Monterey 12.6 ghc 8.10.7 stack 2.9.1 HLS 1.8.0.0

My problem is similar to https://github.com/haskell/haskell-language-server/issues/3134

This is my stack.yaml

resolver: lts-18.28
packages:
  - .

extra-deps:
- hashable-1.3.0.0
- rest-rewrite-0.3.0
- git: https://github.com/ucsd-progsys/liquidhaskell.git
  commit: f917323a1f9db1677e592d6ffc81467d53588d70
  subdirs:
    - .
    - liquid-base
    - liquid-containers
    - liquid-ghc-prim
    - liquid-prelude
- git: https://github.com/ucsd-progsys/liquid-fixpoint.git
  commit: e378d2ee8656da929e41c2d593a88a81e9620391
- unordered-containers-0.2.19.1@sha256:db11042bb0356c0adea277d0794743829125b4c99455af6af2bd5f7bd5e88a39,3797
allow-newer: true
nix:
  packages: ["z3"]

And this is the error i get:

Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.8.0.0 x86_64 ghc-9.4.2
Current directory: /Users/...
Operating system: darwin
Arguments: ["--lsp","-d"]
Cradle directory: /Users/...
Cradle type: Stack

Tool versions found on the $PATH
cabal:          3.8.1.0
stack:          2.9.1
ghc:            8.10.7

Consulting the cradle to get project GHC version...
Project GHC version: 8.10.7
haskell-language-server exe candidates: ["haskell-language-server-8.10.7","haskell-language-server"]
Launching haskell-language-server exe at:/Users/.../.ghcup/tmp/ghcup-ghc-8.10.7_cabal-3.8.1.0_hls-1.8.0.0_stack-2.9.1/haskell-language-server-8.10.7
Failed to find the GHC version of this Stack project.
Error when calling stack exec ghc -- -v0 -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)

<interactive>:0:1: error:
    Not in scope: ‘Control.Monad.join’
    No module named ‘Control.Monad’ is imported.

<interactive>:0:21: error:
    Not in scope: ‘Control.Monad.fmap’
    No module named ‘Control.Monad’ is imported.

<interactive>:0:40: error:
    Not in scope: ‘System.IO.putStr’
    No module named ‘System.IO’ is imported.

<interactive>:0:57: error:
    Not in scope: ‘System.Environment.getExecutablePath’
    No module named ‘System.Environment’ is imported.
mpilgrem commented 1 year ago

@89oinotna, thanks for reporting. However, as you describe it, this appears to relate to HLS and/or GHCup, not Stack. To rule out Stack, what is the code you are seeking to build with that stack.yaml file? I'll try to reproduce what you are experiencing outside of HLS/GHCup. Also, the stack.yaml file appears to be missing the obligatory resolver: key to specify the snapshot.

igormoreno commented 1 year ago

Hi. I'm getting this exact same problem now using this stack file from https://github.com/ucsd-progsys/lh-plugin-demo/

The strange thing (as mentioned in this comment: https://github.com/haskell/haskell-language-server/issues/3134#issuecomment-1242696747) is that the problem happens even if the dependencies are not being used.

A good description of the reproducibility of the problem is in this comment: https://github.com/haskell/haskell-language-server/issues/3134#issuecomment-1237116252