Skip to content

Sensitivity to symlinks in flags from hie-bios #3510

New issue

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

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

Already on GitHub? # to your account

Open
ylecornec opened this issue Mar 1, 2023 · 3 comments
Open

Sensitivity to symlinks in flags from hie-bios #3510

ylecornec opened this issue Mar 1, 2023 · 3 comments
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@ylecornec
Copy link

For context, in rules_haskell we output compilation options as described in the hie-bios documentation, and encountered a case where two different paths to the same directory (because of symlinks) are not equivalent.

See the following repro: https://github.com/ylecornec/hls-symlink-repro.

The repro was made on NixOS but we encountered the same thing on Ubuntu and Windows as well.


In this example ,haskell-language-server is setup using a hie-bios script which outputs the following flags:

  -isubdir_alias
  Main.hs
  subdir/Lib.hs

where subdir_alias is a symbolic link to subdir.

Running the following command:

haskell-language-server-wrapper Main.hs

fails with error:

Message:  Variable not in scope: val

whereas using either subdir or subdir_alias in both places works fine.

(running ghci $(./hie-bios | tr '\n' ' ') as indicated in hie-bios documentation also seems to work fine)

Versions:

This behavior seems present since haskell-language-server version 1.6 as the following commands fail:

nix-shell shell_1_9_0_0.nix --run "haskell-language-server-wrapper Main.hs"
nix-shell shell_1_6_1_1.nix --run "haskell-language-server-wrapper Main.hs"

While this one succeeds:

nix-shell shell_1_5_0_1.nix --run "haskell-language-server-wrapper Main.hs"
@ylecornec ylecornec added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Mar 1, 2023
@fendor
Copy link
Collaborator

fendor commented Mar 1, 2023

Hi, thank you for the bug report!
These darn symlinks, we have been struggling with these since forever 😅

Your issue feels familiar, it looks a bit like #2358 where the consequence of the PR #2359 might be what you are observing here, since we then no longer canonicalise the paths. It is likely caused by that PR, since it was introduced in the 1.6.0.0 versions.

For the record, GHC accepts these options.

To properly fix that, we likely need to take a look at how GHC does it.

@michaelpj
Copy link
Collaborator

Should we move this to hie-bios?

@fendor
Copy link
Collaborator

fendor commented Mar 6, 2023

hie-bios gives the correct flags, the thing is how ghcide sets up the import paths and resolves targets. I think this is a ghcide bug (partially introduced by me) and not a hie-bios one.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
component: ghcide type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

No branches or pull requests

3 participants