Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

hGetContents: invalid argument (invalid byte sequence) on Japanese Windows #667

Closed
@igrep

Description

@igrep

My environment

OS: Windows 10 Pro ver. 1709 build 16299.431
Editor: NVIM v0.2.2
LSP Client: https://github.com/autozimu/LanguageClient-neovim ver. 0.1.93

HIE (extracted from the log file):

hie-wrapper(hie-wrapper) Version 0.2.0.0, Git revision 2a8bad55422cb436b18660dd9238c315b1d9bf82 (1545 commits) x86_64 ghc-8.2.2
HIE(hie-8.2.2.exe) Version 0.2.0.0, Git revision 2a8bad55422cb436b18660dd9238c315b1d9bf82 (1545 commits) x86_64 ghc-8.2.2

Problem

An error is reported when opening a file in a project where some files contains Japanese characters.
From the debug log:

2018-07-04 10:30:51.3777965 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"type":1,"message":"Got error while processing diagnostics: C:\\Users\\yuji-yamamoto\\AppData\\Local\\Temp\\ghc-mod32077\\Experiment32076-0.hs: hGetContents: invalid argument (invalid byte sequence)"},"method":"window/showMessage"}

Suggestion and question

I know the error invalid argument (invalid byte sequence) is a very common error on Japanese Windows related to character encoding.
I've once fixed very similar one in haddock: haskell/haddock#566.
So the solution is perhaps to add hSetEncoding handle utf8 before reading a source file.

Then, where should I fix?
According to the next line of the error in the debug log, hlint is successfully executed:

2018-07-04 10:30:51.3778748 [ThreadId 5] - <--2--{"jsonrpc":"2.0","params":{"uri":"file:///C%3A/s/pj/shioyaki/vendor/haskell-relational-record/relational-query/src/Database/Relational/Experiment.hs","diagnostics":[{"severity":4,"range":{"start":{"line":49,"character":17},"end":{"line":49,"character":83}},"code":"Redundant bracket","source":"hlint","message":"Redundant bracket\nFound:\n  unPlaceholders :: (IxStateT (WriterT PlaceHolderValues m) p1 p2 a)\nWhy not:\n  unPlaceholders :: IxStateT (WriterT PlaceHolderValues m) p1 p2 a\n"},{"severity":4,"range":{"start":{"line":187,"character":17},"end":{"line":187,"character":24}},"code":"Use const","source":"hlint","message":"Use const\nFound:\n  \\ _ -> k\nWhy not:\n  const k\n"}]},"method":"textDocument/publishDiagnostics"}

So the error is caused not by hlint, but ghc-mod, right?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions