Skip to content

Type check error with hls (no error with stack) with a embedded file with non ascii chars #1144

Open
@ishiy1993

Description

@ishiy1993

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

% haskell-language-server-wrapper --probe-tools
haskell-language-server version: 0.7.1.0 (GHC: 8.10.1) (PATH: /home/ishiy/.ghcup/bin/haskell-language-server-wrapper-0.7.1) (GIT hash: e4f677e1780fe85a02b99a09404a0a3c3ab5ce7c)
Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.5.1
ghc:            8.10.2

Which lsp-client do you use: Neovim (coc)

Describe your project (alternative: link to the project): https://github.com/ishiy1993/hls-debug-20210102

Contents of hie.yaml:

cradle:
  stack:
    - path: "./src/Main.hs"
      component: "hls-debug:exe:hls-debug"

    - path: "./src/Lib.hs"
      component: "hls-debug:exe:hls-debug"

Steps to reproduce

git clone git@github.com:ishiy1993/hls-debug-20210102.git
cd hls-debug-20210102
stack build                                          # no error
haskell-language-server-wrapper .    # type check error on src/Main.hs

I use Arch Linux.
The error may not occur on Mac.

Expected behaviour

no error with hls.

Actual behaviour

type check error on src/Main.hs

File:     /home/ishiy/tmp/hls-debug/src/Main.hs
Hidden:   no
Range:    10:12-10:39
Source:   typecheck
Severity: DsError
Message:
  • Exception when trying to run compile-time code:
  greeting.txt: hGetContents: invalid argument (invalid byte sequence)
  Code: embedFile "greeting.txt"
  • In the untyped splice: $(embedFile "greeting.txt")

The error comes from reading a file which includes Japanese with Template Haskell.

Include debug information

Execute in the root of your project the command haskell-language-server --debug . and paste the logs here:

Debug output:
% haskell-language-server-wrapper --debug
Found "/home/ishiy/tmp/hls-debug/hie.yaml" for "/home/ishiy/tmp/hls-debug/a"
Module "/home/ishiy/tmp/hls-debug/a" is loaded by Cradle: Cradle {cradleRootDir = "/home/ishiy/tmp/hls-debug", cradleOptsProg = CradleAction: Stack}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 0.7.1.0, Git revision e4f677e1780fe85a02b99a09404a0a3c3ab5ce7c (dirty) x86_64 ghc-8.10.1
Current directory: /home/ishiy/tmp/hls-debug
Operating system: linux
Arguments: ["--debug"]
Cradle directory: /home/ishiy/tmp/hls-debug
Cradle type: Stack

Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.5.1
ghc:            8.10.2


Consulting the cradle to get project GHC version...
Project GHC version: 8.8.4
haskell-language-server exe candidates: ["haskell-language-server-8.8.4","haskell-language-server-8.8","haskell-language-server"]
Launching haskell-language-server exe at:/home/ishiy/.ghcup/bin/haskell-language-server-8.8.4
haskell-language-server version: 0.7.1.0 (GHC: 8.8.4) (PATH: /home/ishiy/.ghcup/bin/haskell-language-server-8.8.4~0.7.1) (GIT hash: e4f677e1780fe85a02b99a09404a0a3c3ab5ce7c)
(haskell-language-server)Ghcide setup tester in /home/ishiy/tmp/hls-debug.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.5.1
ghc:            8.10.2


Step 1/4: Finding files to test in /home/ishiy/tmp/hls-debug
Found 3 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
[INFO] Consulting the cradle for "src/Lib.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/ishiy/tmp/hls-debug", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `hls-debug' component hls-debug:exe:hls-debug with main-is file: /home/ishiy/tmp/hls-debug/src/Main.hs
> hls-debug> configure (exe)
> Configuring hls-debug-0.1.0.0...
> hls-debug> initial-build-steps (exe)
> Configuring GHCi with the following packages: hls-debug
> /home/ishiy/tmp/hls-debug/.stack-work/install/x86_64-linux-tinfo6/c5edbd47b0c198b85fbf7c5004bc29839215a5df670df1181884a7dd0709cf8d/8.8.4/pkgdb:/home/ishiy/.stack/snapshots/x86_64-linux-tinfo6/c5edbd47b0c198b85fbf7c5004bc29839215a5df670df1181884a7dd0709cf8d/8.8.4/pkgdb:/home/ishiy/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.4/lib/ghc-8.8.4/package.conf.d
[INFO] Using interface files cache dir: ghcide
[INFO] Making new HscEnv[main]
[INFO] Consulting the cradle for "Setup.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/ishiy/tmp/hls-debug", cradleOptsProg = CradleAction: Stack}
File:     /home/ishiy/tmp/hls-debug/Setup.hs
Hidden:   no
Range:    1:1-2:1
Source:   cradle
Severity: DsError
Message:
  Multi Cradle: No prefixes matched
  pwd: /home/ishiy/tmp/hls-debug
  filepath: /home/ishiy/tmp/hls-debug/Setup.hs
  prefixes:
  ("./src/Main.hs",Stack {component = Just "hls-debug:exe:hls-debug", stackYaml = Nothing})
  ("./src/Lib.hs",Stack {component = Just "hls-debug:exe:hls-debug", stackYaml = Nothing})
File:     /home/ishiy/tmp/hls-debug/src/Main.hs
Hidden:   no
Range:    10:12-10:39
Source:   typecheck
Severity: DsError
Message:
  • Exception when trying to run compile-time code:
  greeting.txt: hGetContents: invalid argument (invalid byte sequence)
  Code: embedFile "greeting.txt"
  • In the untyped splice: $(embedFile "greeting.txt")
[INFO] finish: User TypeCheck (took 0.22s)
Files that failed:
 * /home/ishiy/tmp/hls-debug/Setup.hs
 * /home/ishiy/tmp/hls-debug/src/Main.hs

Completed (1 file worked, 2 files failed)
haskell-language-server-wrapper: callProcess: /home/ishiy/.ghcup/bin/haskell-language-server-8.8.4 "--debug" (exit 2): failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    build tool: stackstatus: needs infoNot actionable, because there's missing informationtype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions