Specify freeze file to hls

Can I specify the .freeze file I want hls to use? I am working in a project an using a freeze file (as apparently is the best way to not re-build dependencies).

I was working with hls off as It was slowing down my (already bloated) vscode, and actually not showing any language server info… well it turns out that hls is rebuilding the whole application (which takes like 30 minutes) so it is wating for cabal to build the thing in an isolated folder…

Can I configure hls to use a particular .freeze (equiv. .project) file? I don’t see any space in the settings (vscode) to configure this.

1 Like

What makes you think it isn’t using your project and freeze files? (It is)

HLS does ask cabal to build stuff in a separate build directory. This is because cabal’s use of its working directory is not concurrency safe, so if multiple cabal processes are running at the same time using the same working directory things will break. For example, HLS and a user-launched cabal build. We used to use the project working directory but we switched to an isolated one because of this reason.

That shouldn’t result in rebuilding your dependencies though, since those are shared in the cabal store.

3 Likes

If you want to use a different caba.project file for hls and cabal, you can write a custom hie.yaml:

cradle:
  cabal:
    cabalProject: "cabal.project.hls"

See hie-bios: Set up a GHC API session docs.

2 Likes

Because it is taking an eternity to start. Also, up to the logs hls launches the build with something similar to cabal build --builddir .... That command will download a bunch of dependencies because (I think) cabal defaults to cabal.project[.freeze] file, but I have cabal.my-special-name.project which force me to build with cabal build --project-file=....

I think @fendor 's solution is what I was looking for!

If you don’t build your project normally with just cabal build, then yeah, you might need to tell HLS about that! What Fendor suggests will help there.

1 Like