Skip to content

Modules in subdirectories are looked for with the wrong path. #498

Closed
@nerfingen

Description

@nerfingen

Subject of the issue

I have a small stack project of the form:

.
├── app
│   ├── Dir
│   │   └── Func.hs
│   └── Main.hs
├── haskell-language-test.cabal
├── package.yaml
├── Setup.hs
├── stack.yaml
└── stack.yaml.lock

If I try to use the haskell-language-server to get information about Func.hs I only get the message:

  Multi Cradle: No prefixes matched
  pwd: /home/nerf/git/haskell-language-test
  filepath: /home/nerf/git/haskell-language-test/app/Dir/Func.hs
  prefixes:
  ("./app/Main.hs",Stack {component = Just "haskell-language-test:exe:haskell-language-test-exe",
  stackYaml = Nothing})
  ("./app/Dir.Func.hs",Stack {component = Just
  "haskell-language-test:exe:haskell-language-test-exe", stackYaml = Nothing})
  ("./app/Paths_haskell_language_test.hs",Stack {component = Just
  "haskell-language-test:exe:haskell-language-test-exe", stackYaml = Nothing})

It seems to look for the file Dir.Func.hs instead of Dir/Func.hs. Even though the GHC Userguide section 6.8.1 says:

Usually, the file should be named after the module name, replacing dots in the module name by directory separators.

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.5.0.0 (GHC: 8.10.1) (PATH: /usr/bin/haskell-language-server-wrapper) (GIT hash: 14497f2503a2a0d389fabf3b146d674b9af41a34)
Tool versions found on the $PATH
cabal:		2.0.0.1
stack:		2.3.1
ghc:		8.10.2
  • Which lsp-client do you use
    • I use kakoune with the lsp-kak plugin, but I could reproduce this also only using haskell-language-server-wrapper --debug.
  • Describe your project (alternative: link to the project)
    • Include stack.yaml
# This file was automatically generated by 'stack init'
#
# Some commonly used options have been documented as comments in this file.
# For advanced use and comprehensive documentation of the format, please see:
# https://docs.haskellstack.org/en/stable/yaml_configuration/

# Resolver to choose a 'specific' stackage snapshot or a compiler version.
# A snapshot resolver dictates the compiler version and the set of packages
# to be used for project dependencies. For example:
#
# resolver: lts-3.5
# resolver: nightly-2015-09-21
# resolver: ghc-7.10.2
#
# The location of a snapshot can be provided as a file or url. Stack assumes
# a snapshot provided as a file might change, whereas a url resource does not.
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver:
  url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/15.yaml

# User packages to be built.
# Various formats can be used as shown in the example below.
#
# packages:
# - some-directory
# - https://example.com/foo/bar/baz-0.0.2.tar.gz
#   subdirs:
#   - auto-update
#   - wai
packages:
- .
# Dependency packages to be pulled from upstream that are not in the resolver.
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example:
#
# extra-deps:
# - acme-missiles-0.3
# - git: https://github.com/commercialhaskell/stack.git
#   commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a
#
# extra-deps: []

# Override default flag values for local packages and extra-deps
# flags: {}

# Extra package databases containing global packages
# extra-package-dbs: []

# Control whether we use the GHC we find on the path
# system-ghc: true
#
# Require a specific version of stack, using version ranges
# require-stack-version: -any # Default
# require-stack-version: ">=2.3"
#
# Override the architecture used by stack, especially useful on Windows
# arch: i386
# arch: x86_64
#
# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor
  • Include package.yaml
name:                haskell-language-test
version:             0.1.0.0
github:              "githubuser/haskell-language-test"
license:             BSD3
author:              "Author name here"
maintainer:          "example@example.com"
copyright:           "2020 Author name here"


# Metadata used when publishing your package
# synopsis:            Short description of your package
# category:            Web

# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description:         Please see the README on GitHub at <https://github.com/githubuser/haskell-language-test#readme>

dependencies:
- base >= 4.7 && < 5

executables:
  haskell-language-test-exe:
    main:                Main.hs
    source-dirs:         app
    ghc-options:
    - -threaded
    - -rtsopts
    - -with-rtsopts=-N
  • Include *.cabal files
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.34.2.
--
-- see: https://github.com/sol/hpack

name:           haskell-language-test
version:        0.1.0.0
description:    Please see the README on GitHub at <https://github.com/githubuser/haskell-language-test#readme>
homepage:       https://github.com/githubuser/haskell-language-test#readme
bug-reports:    https://github.com/githubuser/haskell-language-test/issues
author:         Author name here
maintainer:     example@example.com
copyright:      2020 Author name here
license:        BSD3
build-type:     Simple

source-repository head
  type: git
  location: https://github.com/githubuser/haskell-language-test

executable haskell-language-test-exe
  main-is: Main.hs
  other-modules:
      Dir.Func
      Paths_haskell_language_test
  hs-source-dirs:
      app
  ghc-options: -threaded -rtsopts -with-rtsopts=-N
  build-depends:
      base >=4.7 && <5
  default-language: Haskell2010
  • Include cabal.project
    • there is none
  • Contents of hie.yaml
    • there is none

Steps to reproduce

Make a similar small stack project with a module in a subdirectory. Then run haskell-language-server-wrapper --debug.

Expected behaviour

It should give print analyitcs to all modules (and debug information).

Actual behaviour

For modules in subdirectories it only outputs the error message from above.

Include debug information

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

Debug output:
Module "/home/nerf/git/haskell-language-test/a" is loaded by Cradle: Cradle {cradleRootDir = "/home/nerf/git/haskell-language-test", cradleOptsProg = CradleAction: Stack}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 0.5.0.0, Git revision 14497f2503a2a0d389fabf3b146d674b9af41a34 (dirty) x86_64 ghc-8.10.1
Current directory: /home/nerf/git/haskell-language-test
Operating system: linux
Arguments: ["--debug"]
Cradle directory: /home/nerf/git/haskell-language-test
Cradle type: Stack

Tool versions found on the $PATH
cabal:		2.0.0.1
stack:		2.3.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:/usr/bin/haskell-language-server-8.8.4
haskell-language-server version: 0.5.0.0 (GHC: 8.8.4) (PATH: /usr/bin/haskell-language-server-8.8.4) (GIT hash: 14497f2503a2a0d389fabf3b146d674b9af41a34)
(haskell-language-server)Ghcide setup tester in /home/nerf/git/haskell-language-test.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Tool versions found on the $PATH
cabal:		2.0.0.1
stack:		2.3.1
ghc:		8.10.2


Step 1/4: Finding files to test in /home/nerf/git/haskell-language-test
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 "Setup.hs"
NotShowMessage (NotificationMessage {_jsonrpc = "2.0", _method = WindowShowMessage, _params = ShowMessageParams {_xtype = MtWarning, _message = "No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for Setup.hs.\n Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie)"}})
Output from setting up the cradle Cradle {cradleRootDir = "/home/nerf/git/haskell-language-test", cradleOptsProg = CradleAction: Stack}
File:     /home/nerf/git/haskell-language-test/Setup.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message: 
  Multi Cradle: No prefixes matched
  pwd: /home/nerf/git/haskell-language-test
  filepath: /home/nerf/git/haskell-language-test/Setup.hs
  prefixes:
  ("./app/Main.hs",Stack {component = Just "haskell-language-test:exe:haskell-language-test-exe",
  stackYaml = Nothing})
  ("./app/Dir.Func.hs",Stack {component = Just
  "haskell-language-test:exe:haskell-language-test-exe", stackYaml = Nothing})
  ("./app/Paths_haskell_language_test.hs",Stack {component = Just
  "haskell-language-test:exe:haskell-language-test-exe", stackYaml = Nothing})
[INFO] Consulting the cradle for "app/Dir/Func.hs"
NotShowMessage (NotificationMessage {_jsonrpc = "2.0", _method = WindowShowMessage, _params = ShowMessageParams {_xtype = MtWarning, _message = "No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for app/Dir/Func.hs.\n Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie)"}})
Output from setting up the cradle Cradle {cradleRootDir = "/home/nerf/git/haskell-language-test", cradleOptsProg = CradleAction: Stack}
File:     /home/nerf/git/haskell-language-test/app/Dir/Func.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message: 
  Multi Cradle: No prefixes matched
  pwd: /home/nerf/git/haskell-language-test
  filepath: /home/nerf/git/haskell-language-test/app/Dir/Func.hs
  prefixes:
  ("./app/Main.hs",Stack {component = Just "haskell-language-test:exe:haskell-language-test-exe",
  stackYaml = Nothing})
  ("./app/Dir.Func.hs",Stack {component = Just
  "haskell-language-test:exe:haskell-language-test-exe", stackYaml = Nothing})
  ("./app/Paths_haskell_language_test.hs",Stack {component = Just
  "haskell-language-test:exe:haskell-language-test-exe", stackYaml = Nothing})
[INFO] Consulting the cradle for "app/Main.hs"
NotShowMessage (NotificationMessage {_jsonrpc = "2.0", _method = WindowShowMessage, _params = ShowMessageParams {_xtype = MtWarning, _message = "No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for app/Main.hs.\n Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie)"}})
Output from setting up the cradle Cradle {cradleRootDir = "/home/nerf/git/haskell-language-test", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `haskell-language-test' component haskell-language-test:exe:haskell-language-test-exe with main-is file: /home/nerf/git/haskell-language-test/app/Main.hs
> The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
> Configuring GHCi with the following packages: haskell-language-test
> /home/nerf/git/haskell-language-test/.stack-work/install/x86_64-linux-tinfo6/28176f85f0c2e9165cba912d54bfbbb7a2e389618a713e369c70d35fdcbab556/8.8.4/pkgdb:/home/nerf/.stack/snapshots/x86_64-linux-tinfo6/28176f85f0c2e9165cba912d54bfbbb7a2e389618a713e369c70d35fdcbab556/8.8.4/pkgdb:/home/nerf/.stack/programs/x86_64-linux/ghc-tinfo6-8.8.4/lib/ghc-8.8.4/package.conf.d
[INFO] Using interface files cache dir: /home/nerf/.cache/ghcide/main-393e788d981953c5fcb59b30097d3225d469a5ea
[INFO] Making new HscEnv[main]
[INFO] Consulting the cradle for "Setup.hs"
NotShowMessage (NotificationMessage {_jsonrpc = "2.0", _method = WindowShowMessage, _params = ShowMessageParams {_xtype = MtWarning, _message = "No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for Setup.hs.\n Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie)"}})
Output from setting up the cradle Cradle {cradleRootDir = "/home/nerf/git/haskell-language-test", cradleOptsProg = CradleAction: Stack}
Files that failed:
 * /home/nerf/git/haskell-language-test/Setup.hs

Completed (2 files worked, 1 file failed)
[INFO] finish: User TypeCheck (took 0.06s)
haskell-language-server-wrapper: callProcess: /usr/bin/haskell-language-server-8.8.4 "--debug" (exit 1): failed

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

LSP logs:
*** This is the debug buffer, where debug info will be written ***
Enabling LSP for filetype haskell
Config-change detected:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions