2

I have a project that looks like this:

- my-project
  - backend
    - stack.yaml
    - src
      - ... a bunch of haskell files
    - ... exe & test folders here too
  - frontend
    - ... an Elm frontend app
  - flake.nix
  - ... other files

When I open this in vscode (cd my-project && codium .) and go to one of the haskell files I get some errors it cannot find packages.

However, when I first cd into the backend folder and then open code (cd my-project/backend && codium .) then everything works perfectly.

So I think the HLS is just being started at the root and then not able to pick up the haskell project properly.

I tried adding "haskell.serverExtraArgs": "--cwd /home/theoddler/Dev/my-project/backend" to my .vscode/.settings.json file, but I get the same errors.

How do I fix this? Can I change the directory where the vscode plugin starts the HLS?

duplode
  • 33,731
  • 7
  • 79
  • 150
The Oddler
  • 6,314
  • 7
  • 51
  • 94

1 Answers1

0

Workaround

I moved the stack.yaml,stack.yaml.lock files to the root, and changed packages in the stack.yaml file from

packages:
  - .

to

packages:
  - backend

That way the HLS is happy and can find my Haskell project properly.

Other thoughts

I looked into the code of the vscode-haskell extension, and it looks like it doesn't support anything other than the root as the directory for HLS for workspaces.

I'm looking into contributing to the vscode haskell extension, adding the functionality to change the working dir for the HLS, but currently my setup for debugging the changes of extensions isn't working, so I'll look into that again later.

For now the workaround is the best I found :(

The Oddler
  • 6,314
  • 7
  • 51
  • 94