dense-analysis / dense-analysis/ale

ALE doesn't run haskell lint/fixers from the project root directory and so misses errors

Open
#3,140 2 comments 6 reactions 0 assignees View on GitHub
bug
Dominant language
Vim Script
Stars
14k
Forks
1.5k
Avg merge
17h 49m
Merged PRs (30d)
1

Description

## Information

**VIM version**

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 19 2020 22:40:28)
macOS version
Included patches: 1-600
Compiled by Homebrew
Huge version without GUI.

Operating System: MacOS Catalina

## What went wrong

Suppose that I have a haskell project with `.cabal` file at its root and edit a file in a subdirectory (`src` say) from the root directory (or anywhere else) then both `ghc` and `cabal` fail to produce the correct diagnostics because they expect to be run from the project root directory, rather than from the location of the file I am editing.

## Reproducing the bug

1. `vim src/Smuggler/Import.hs` from the project root directory (`/Users/jrp/Documents/Haskell/smuggler`)

2. Then the `hlint`ing and some `ghc` errors are shown, but the latter are not correct. That is because ALE calls `cabal` and `ghc` from the location of the file (`/Users/jrp/Documents/Haskell/smuggler/src/Smuggler`), rather than the project root directory, as can be seen from the trace below. `hlint` works OK.

### :ALEInfo

```
Command History:
(executable check - success) cabal
(finished - exit code 1) ['/bin/zsh', '-c', 'cd ''/Users/jrp/Documents/Haskell/smuggler/src/Smuggler'' && cabal exec -- ghc -fno-co
de -v0 ''/var/folders/nc/w49hkt7n3zvd88xtqmgklcpc0000gn/T/vq6ySSL/1/Import.hs''']
<<>>
No cabal.project file or cabal file matching the default glob './*.cabal' was found.
Please create a package description file .cabal or a cabal.project file referencing the packages you want to build.
<<>>
(executable check - success) ghc
(finished - exit code 1) ['/bin/zsh', '-c', 'ghc -fno-code -v0 ''/var/folders/nc/w49hkt7n3zvd88xtqmgklcpc0000gn/T/vq6ySSL/2/Import.
hs''']
<<>>
Name.hs:1:8: error:
File name does not match module name:
Saw: ‘Smuggler.Name’
Expected: ‘Name’
|
1 | module Smuggler.Name
| ^^^^^^^^^^^^^
<<>>
(executable check - failure) ghc-mod
(executable check - failure) hdevtools
(executable check - failure) hie
(executable check - success) hlint
(finished - exit code 1) ['/bin/zsh', '-c', '''hlint'' --color=never --json - < ''/var/folders/nc/w49hkt7n3zvd88xtqmgklcpc0000gn/T
/vq6ySSL/3/Import.hs''']
<<>>
[{"module":["Smuggler.Import"],"decl":[],"severity ...
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.