Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eval Plugin can't handle local module imports even if they are explicitly listed in exposed-modules #485

Closed
konn opened this issue Oct 10, 2020 · 3 comments · Fixed by #488
Labels
component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@konn
Copy link
Collaborator

konn commented Oct 10, 2020

Subject of the issue

The Eval Plugin in hls-0.5.0.0 seems incapable of treating local module imports properly.

Your environment

  • Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools
    (Using precompiled binary automatically downloaded by vscode-haskell)

    haskell-language-server version: 0.5.0.0 (GHC: 8.10.1) (PATH: /Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-wrapper-0.5.0-darwin) (GIT hash: 14497f2503a2a0d389fabf3b146d674b9af41a34)
    Tool versions found on the $PATH
    cabal:          3.2.0.0
    stack:          2.3.3
    
  • Which lsp-client do you use: VS Code

  • Describe your project: Minimal Repro here

  • Contents of hie.yaml: contained in the above repro.

Steps to reproduce

  1. Open the above repro project with favourite code editor
  2. Open lib/Lib/API.hs and wait for HLS to load package successfully.
    • Confirm that no errors are reported so far.
  3. After Evaluate... appears above -- >>> "hello", click Evaluate....
  4. Save Lib.API again.

Expected behaviour

  • Step 3 should adds a line saying "hello" below the doctest comment.
  • Step 4 should save the new content and no error must be reported.

Actual behaviour

  • In Step 3, Eval plugin silently fails and Output of HLS says (stack cradle):

    [Error - 13:15:22] Request workspace/executeCommand failed.
      Message: Could not find module ‘Lib.API.Loaded’
    

    A cabal cradle gives a slightly different (but seems essentially the same) error message:

    [Error - 13:18:21] Request workspace/executeCommand failed.
      Message: These modules are needed for compilation but not listed in your .cabal file's other-modules: 
        Lib.API.LoadedCould not find module ‘Lib.API.Loaded’
    It is not a module in the current program, or in any known package.
      Code: -32603 
    
  • After Step 4: import of Lib.API.Loaded get highlighted as error and HLS reports Could not find module ‘Lib.API.Loaded’.
    スクリーンショット 2020-10-10 13 17 02

Include debug information

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

Debug output:
$ ~/Library/Application\ Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.5.0-darwin-8.6.5 --debug .
haskell-language-server version: 0.5.0.0 (GHC: 8.6.5) (PATH: /Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.5.0-darwin-8.6.5) (GIT hash: 14497f2503a2a0d389fabf3b146d674b9af41a34)
(haskell-language-server)Ghcide setup tester in /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.3.3
ghc:            8.6.5


Step 1/4: Finding files to test in /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods
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 "lib/Lib/API.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods", cradleOptsProg = CradleAction: Stack}
> Error parsing targets: Unknown local package: lib
> Note that to specify options to be passed to GHCi, use the --ghci-options flag
> /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/.stack-work/install/x86_64-osx/f8a53e261b74c90987b14f60d7c7bebcf4986423df23465fe9b1fa4b552d03ca/8.6.5/pkgdb:/Users/hiromi/.stack/snapshots/x86_64-osx/f8a53e261b74c90987b14f60d7c7bebcf4986423df23465fe9b1fa4b552d03ca/8.6.5/pkgdb:/Users/hiromi/.stack/programs/x86_64-osx/ghc-8.6.5/lib/ghc-8.6.5/package.conf.d
File:     /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/lib/Lib/API.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message: 
  Failed to parse result of calling stack
  Error parsing targets: Unknown local package: lib
  Note that to specify options to be passed to GHCi, use the --ghci-options flag
[INFO] Consulting the cradle for "Setup.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods", cradleOptsProg = CradleAction: Stack}
File:     /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/Setup.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message: 
  Multi Cradle: No prefixes matched
  pwd: /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods
  filepath: /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/Setup.hs
  prefixes:
  ("lib",Stack {component = Just "lib:hls-eval-multimods", stackYaml = Nothing})
[INFO] Consulting the cradle for "lib/Lib/API/Loaded.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods", cradleOptsProg = CradleAction: Stack}
> Error parsing targets: Unknown local package: lib
> Note that to specify options to be passed to GHCi, use the --ghci-options flag
> /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/.stack-work/install/x86_64-osx/f8a53e261b74c90987b14f60d7c7bebcf4986423df23465fe9b1fa4b552d03ca/8.6.5/pkgdb:/Users/hiromi/.stack/snapshots/x86_64-osx/f8a53e261b74c90987b14f60d7c7bebcf4986423df23465fe9b1fa4b552d03ca/8.6.5/pkgdb:/Users/hiromi/.stack/programs/x86_64-osx/ghc-8.6.5/lib/ghc-8.6.5/package.conf.d
File:     /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/lib/Lib/API/Loaded.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message: 
  Failed to parse result of calling stack
  Error parsing targets: Unknown local package: lib
  Note that to specify options to be passed to GHCi, use the --ghci-options flag
Files that failed:
[INFO] finish: User TypeCheck (took 1.63s)
 * /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/Setup.hs
 * /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/lib/Lib/API.hs
 * /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/lib/Lib/API/Loaded.hs

Paste the logs from the lsp-client, e.g. for VS Code

LSP logs:
[client] run command: "/Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.5.0-darwin-8.6.5 --lsp"
[client] debug command: "/Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.5.0-darwin-8.6.5 --lsp"
[client] server cwd: undefined
haskell-language-server version: 0.5.0.0 (GHC: 8.6.5) (PATH: /Users/hiromi/Library/Application Support/Code/User/globalStorage/haskell.haskell/haskell-language-server-0.5.0-darwin-8.6.5) (GIT hash: 14497f2503a2a0d389fabf3b146d674b9af41a34)
Starting (haskell-language-server)LSP server...
  with arguments: LspArguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "brittany",PluginId "eval",PluginId "floskell",PluginId "fourmolu",PluginId "ghcide",PluginId "importLens",PluginId "ormolu",PluginId "pragmas",PluginId "retrie",PluginId "stylish-haskell",PluginId "tactic"]
  in directory: /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.01s
2020-10-10 13:20:32.298036 [ThreadId 25] - Registering ide configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri 8100567079871259705 "file:///Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods"], clientSettings = hashed Nothing}
2020-10-10 13:20:32.301381 [ThreadId 25] - Configuration changed: Object (fromList [("haskell",Object (fromList [("hlint",Object (fromList [("logLevel",String "info"),("executablePath",String "/Users/hiromi/.local/bin/hlint")])),("logFile",String ""),("hlintOn",Bool True),("formatOnImportOn",Bool True),("indentationRules",Object (fromList [("enabled",Bool True)])),("liquidOn",Bool False),("languageServerVariant",String "haskell-language-server"),("serverExecutablePath",String ""),("diagnosticsOnChange",Bool True),("completionSnippetsOn",Bool True),("maxNumberOfProblems",Number 100.0),("formattingProvider",String "none"),("trace",Object (fromList [("server",String "off")]))]))])
2020-10-10 13:20:32.302772 [ThreadId 25] - Opened text document: file:///Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/lib/Lib/API.hs
2020-10-10 13:20:32.304771 [ThreadId 97] - Consulting the cradle for "lib/Lib/API.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods", cradleOptsProg = CradleAction: Cabal}
2020-10-10 13:20:32.576474 [ThreadId 112] - Plugin.makeCodeLens (ideLogger)
> Resolving dependencies...
> Build profile: -w ghc-8.6.5 -O1
> In order, the following will be built (use -v for more details):
>  - hls-eval-multimods-0.1.0.0 (lib) (configuration changed)
> Configuring library for hls-eval-multimods-0.1.0.0..
> Preprocessing library for hls-eval-multimods-0.1.0.0..
2020-10-10 13:20:36.979503 [ThreadId 119] - GhcIde.hover entered (ideLogger)
2020-10-10 13:20:36.979691 [ThreadId 119] - Hover request at position 4:10 in file: /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/lib/Lib/API.hs
2020-10-10 13:20:38.928932 [ThreadId 126] - GhcIde.hover entered (ideLogger)
2020-10-10 13:20:38.92911 [ThreadId 126] - Hover request at position 4:11 in file: /Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/lib/Lib/API.hs
2020-10-10 13:20:39.280646 [ThreadId 97] - Using interface files cache dir: /Users/hiromi/.cache/ghcide/hls-eval-multimods-0.1.0.0-inplace-5a334cfebf708d9ef1e69378cd54cd3fdd121053
2020-10-10 13:20:39.280884 [ThreadId 97] - Making new HscEnv[hls-eval-multimods-0.1.0.0-inplace]
2020-10-10 13:20:39.401462 [ThreadId 283] - finish: codeLens (took 0.03s)
2020-10-10 13:20:39.402233 [ThreadId 298] - finish:  (took 0.00s)
2020-10-10 13:20:40.579169 [ThreadId 307] - finish: runEvalCmd.ghcSession (took 0.00s)
2020-10-10 13:20:40.579378 [ThreadId 309] - finish: runEvalCmd.getModSummary (took 0.00s)
[Error - 13:20:40] Request workspace/executeCommand failed.
  Message: These modules are needed for compilation but not listed in your .cabal file's other-modules: 
    Lib.API.LoadedCould not find module ‘Lib.API.Loaded’
It is not a module in the current program, or in any known package.
  Code: -32603 
2020-10-10 13:20:43.613224 [ThreadId 25] - Saved text document: file:///Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/lib/Lib/API.hs
2020-10-10 13:20:43.616153 [ThreadId 392] - Typechecking reverse dependencies forNormalizedFilePath "/Users/hiromi/Documents/Programming/Haskell/git/hls-eval-multimods/lib/Lib/API.hs": []
@konn
Copy link
Collaborator Author

konn commented Oct 10, 2020

IIRC, this bug doesn't present in <= 0.4; so some changes after 0.4 should be related to this?

@konn
Copy link
Collaborator Author

konn commented Oct 10, 2020

Only suspicious change is a change from GhcSession to GhcSessionDeps in 1d1ab3b, but it seems that even if we revert to GhcSession the above behaviour remains unchanged... perhaps an upstream bug in ghcide?

@pepeiborra
Copy link
Collaborator

There's one change upstream in ghcide to remove the import-dirs from the Ghc session which would likely break the :import command in the Eval plugin, but I'm not sure how it would break source imports. I'll have a look.

This was referenced Oct 10, 2020
@jneira jneira added component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Oct 10, 2020
@jneira jneira linked a pull request Oct 10, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: hls-eval-plugin type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants