Skip to content

HLS can't find symlinked Modules #2358

Closed
@fendor

Description

@fendor

Steps to reproduce

Project structure

.
├── _ghci
│   └── Sym.hs -> /home/hugin/Documents/haskell/hls-bug2/some_loc/Sym.hs
├── hie.yaml
├── some_loc
│   └── Sym.hs
└── src
    └── Foo.hs

where hie.yaml is:

cradle:
  direct:
    arguments:
      - -i
      - -isrc
      - -i_ghci/
      - _ghci/Sym.hs
      - src/Foo.hs

and Foo.hs imports Sym.hs.

The following script generates this project:

Generate project
#!/usr/bin/env bash

mkdir _ghci some_loc src
echo -e "module Foo where\n\nimport Sym\n" > src/Foo.hs
echo -e "module Sym where foo = \"\"" > some_loc/Sym.hs
ln -s $(pwd)/some_loc/Sym.hs _ghci/Sym.hs

echo "" > hie.yaml # create empty hie.yaml
echo "cradle:" >> hie.yaml
echo "  direct:" >> hie.yaml
echo "    arguments:" >> hie.yaml
echo "      - -i" >> hie.yaml
echo "      - -isrc" >> hie.yaml
echo "      - -i_ghci/" >> hie.yaml
echo "      - _ghci/Sym.hs" >> hie.yaml
echo "      - src/Foo.hs" >> hie.yaml

Expected behaviour

HLS should be able to load this project, just like ghc:

> ghc -i -isrc -i_ghci/ _ghci/Sym.hs src/Foo.hs
[1 of 2] Compiling Sym              ( _ghci/Sym.hs, _ghci/Sym.o )
[2 of 2] Compiling Foo              ( src/Foo.hs, src/Foo.o )

and hie-bios:

> hie-bios check src/Foo.hs
src/Foo.hs:3:1:Warning: The import of ‘Sym’ is redundant
  except perhaps to import instances from ‘Sym’
To import instances alone, use: import Sym()

Actual behaviour

However, the following error is shown:

> haskell-language-server-8.10.7 src/Foo.hs
haskell-language-server version: 1.4.0.0 (GHC: 8.10.7) (PATH: /home/hugin/.ghcup/bin/haskell-language-server-8.10.7~1.4.0) (GIT hash: 253547816ee216c53ee7dacc0ad3cac43e863d30)
 ghcide setup tester in /home/hugin/Documents/haskell/hls-bug2.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /home/hugin/Documents/haskell/hls-bug2
Found 1 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  (/home/hugin/Documents/haskell/hls-bug2/hie.yaml)

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
2021-11-16 10:19:35.405428645 [ThreadId 51] INFO hls:	Consulting the cradle for "src/Foo.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/home/hugin/Documents/haskell/hls-bug2", cradleOptsProg = CradleAction: Direct}
2021-11-16 10:19:35.484578014 [ThreadId 51] INFO hls:	Using interface files cache dir: /home/hugin/.cache/ghcide/main-066636b74adb0ec22204dccf3a86bd38674b1c5a
2021-11-16 10:19:35.484741616 [ThreadId 51] INFO hls:	Making new HscEnv[main]
2021-11-16 10:19:35.503112003 [ThreadId 138] INFO hls:	File:     /home/hugin/Documents/haskell/hls-bug2/src/Foo.hs
Hidden:   no
Range:    3:8-3:11
Source:   not found
Severity: DsError
Message: 
  Could not find module ‘Sym’
  It is not a module in the current program, or in any known package.
2021-11-16 10:19:35.503728548 [ThreadId 146] INFO hls:	finish: User TypeCheck (took 0.01s)
Files that failed:
 * /home/hugin/Documents/haskell/hls-bug2/src/Foo.hs
2021-11-16 10:19:35.503915219 [ThreadId 148] INFO hls:	finish: GetHie (took 0.00s)

2021-11-16 10:19:35.504074281 [ThreadId 151] INFO hls:	finish: GenerateCore (took 0.00s)
Completed (0 files worked, 1 file failed)

I think there are some duplicates of this issue, usually where the modules point into the nix-store, but I couldn't find them right away.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions