Ale: Ale might not find imported modules when ale_linters includes both stack and non-stack ghc sources...

Created on 18 Feb 2018  路  3Comments  路  Source: dense-analysis/ale

Information

VIM version

NVIM v0.2.2
Release

Operating System: Mac OS 10.13.3

:ALEInfo

Current Filetype: haskell
Available Linters: ['ghc-mod', 'stack-ghc-mod', 'ghc', 'hdevtools', 'hlint', 'stack-build', 'stack-ghc']
Enabled Linters: ['hdevtools', 'hlint', 'stack-build', 'stack-ghc']
Linter Variables:

let g:ale_haskell_hdevtools_executable = 'hdevtools'
let g:ale_haskell_hdevtools_options = '-g -Wall'
Global Variables:

let g:ale_cache_executable_check_failures = 0
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = 100
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = 50
let g:ale_echo_cursor = 1
let g:ale_echo_msg

What went wrong

Incorrectly reports "cannot find module" when I include ghc in the list of linters.

Reproducing the bug

Steps for repeating the bug:

  1. import Numeric.Sum
  2. watch Ale report an error
  3. remove ghc as a linter (or specify a list of linters that excludes ghc)
  4. watch Ale behave as expected.... no error.

Note: The title says "might". I believe I'm getting this issue because I only use stack. I don't have the modules installed in a way that only uses cabal. So, if you have both approaches working, I don't expect a person would experience this issue. However, given how stack is becoming the preferred manager, and how ghc-mod also now works with stack, I expect this might become an issue for more and more users.

Most helpful comment

For for anyone that sees this and want's to only disable GHC linting in stack projects:

~/.config/nvim/init.vim (or ~/.vimrc if not using neovim)

function CheckIfFileExists(filename)
  if filereadable(a:filename)
    return 1
  endif

  return 0
endfunction

...

" Disable GHC linter if in a Haskell Stack project
if (CheckIfFileExists("./stack.yaml") == 1)
  let g:ale_linters = {
  \   'haskell': ['stack-build'], " you can include any other linters in this list too
  \}
endif

All 3 comments

I am having the same issue while using neovim under a nix-shell that contains only ghc and cabal. I can get stack to work, however I'm no longer using stack as part of my dev system.

Sounds like you just need to turn ghc off on your machine, then. I don't think there's anything that can be done about this.

For for anyone that sees this and want's to only disable GHC linting in stack projects:

~/.config/nvim/init.vim (or ~/.vimrc if not using neovim)

function CheckIfFileExists(filename)
  if filereadable(a:filename)
    return 1
  endif

  return 0
endfunction

...

" Disable GHC linter if in a Haskell Stack project
if (CheckIfFileExists("./stack.yaml") == 1)
  let g:ale_linters = {
  \   'haskell': ['stack-build'], " you can include any other linters in this list too
  \}
endif
Was this page helpful?
0 / 5 - 0 ratings

Related issues

alexlafroscia picture alexlafroscia  路  4Comments

glepnir picture glepnir  路  3Comments

Integralist picture Integralist  路  4Comments

plexigras picture plexigras  路  3Comments

trevordmiller picture trevordmiller  路  3Comments