Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

VSCode: Haskell language server fails when internal-libraries is used in package.yaml #2953

Closed
sumit2bk opened this issue Jun 12, 2022 · 9 comments
Labels
build tool: stack status: blocked Not actionable, because blocked by upstream/GHC etc.

Comments

@sumit2bk
Copy link

sumit2bk commented Jun 12, 2022

I have a haskell project that I created using stack. The VSCode haskell extension works fine until I add "internal-libraries" component in stack's package.yaml file.

Below is error that I see in output section of VSCode:
image

Below is the content of package.yaml that cause extension to fail:

image

@sumit2bk
Copy link
Author

image

@fendor
Copy link
Collaborator

fendor commented Jun 13, 2022

Stack's support for internal libraries is lacking: commercialhaskell/stack#4564

In other words, stack repl doesn't work for internal libraries, so we are stuck and can't load the component.

@michaelpj michaelpj added the status: blocked Not actionable, because blocked by upstream/GHC etc. label Jun 14, 2022
@mpilgrem
Copy link

@fendor, on "stack repl doesn't work for internal libraries" things may have moved on.

For example, with the master branch version of Stack (which is soon to be Stack 2.15.1) and the pantry package (which uses an internal library named internal in ./int), stack ghci/stack repl works fine.

However, I do have a problem. I am using .hie.yaml:

cradle:
  stack:
  - path: "./src"
    component: "pantry:lib"
  - path: "./int"
    component: "pantry:lib"
  - path: "./app"
    component: "pantry:exe:test-pretty-exceptions"
  - path: "./test"
    component: "pantry:test:spec"

All the modules (including those modules of the internal library) 'work' with HLS except those modules that import modules from the internal library. For those exceptions, the HLS error is:

Could not load module ‘Pantry.Types’
It is a member of the hidden package ‘pantry-0.9.3.1:internal’.
You can run ‘:set -package pantry’ to expose it.
(Note: this unloads all the modules in the current scope.)

@fendor
Copy link
Collaborator

fendor commented Dec 16, 2023

@mpilgrem

I built stack from latest master, but stack repl doesn't work for me out of the box, see:

> ~/.local/bin/stack repl pantry:lib

Warning: nix (Nix) 2.18.1 is on the PATH (at /home/hugin/.nix-profile/bin/nix) but Stack's Nix integration is disabled. To mute this message in future, set notify-if-nix-on-path: false in Stack's
         configuration.
         
pantry> initial-build-steps (lib + sub-lib)
Configuring GHCi with the following packages: pantry.
GHCi, version 9.4.8: https://www.haskell.org/ghc/  :? for help
[ 1 of 12] Compiling Pantry.HTTP      ( /home/hugin/Documents/haskell/pantry/src/Pantry/HTTP.hs, interpreted )

/home/hugin/Documents/haskell/pantry/src/Pantry/HTTP.hs:29:1: error:
    Could not find module ‘Pantry.SHA256’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
29 | import qualified Pantry.SHA256 as SHA256
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/home/hugin/Documents/haskell/pantry/src/Pantry/HTTP.hs:30:1: error:
    Could not find module ‘Pantry.Types’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
30 | import           Pantry.Types
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
[ 3 of 12] Compiling Pantry.SQLite    ( /home/hugin/Documents/haskell/pantry/src/Pantry/SQLite.hs, interpreted )

/home/hugin/Documents/haskell/pantry/src/Pantry/SQLite.hs:20:1: error:
    Could not find module ‘Pantry.Types’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
20 | import           Pantry.Types ( PantryException (..), Storage (..) )
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[10 of 12] Compiling System.IsWindows ( /home/hugin/Documents/haskell/pantry/src/unix/System/IsWindows.hs, interpreted )
Failed, one module loaded.

<no location info>: error:
    Could not find module ‘Hackage.Security.Client.Repository.HttpLib.HttpClient’
    Perhaps you meant
      Hackage.Security.Client.Repository.HttpLib (from hackage-security-0.6.2.3)
Loaded GHCi configuration from /home/hugin/.cache/stack/ghci-script/33bb9360/ghci-script
ghci> hie-bios eb
ghci> :q
Leaving GHCi.

~/.local/bin/stack build seems to succeed, but even then ~/.local/bin/stack repl pantry:lib doesn't work for me.

@mpilgrem
Copy link

@fendor, thanks for digging into this. I was trying stack repl or stack repl pantry (which works) and I agree that stack repl pantry:lib does not. That gives me something to investigate further at the Stack end.

@mpilgrem
Copy link

@fendor, thanks to the work of @theobat, stack repl pantry:lib (etc) is now fixed in the master branch version of Stack, and my .hie works (once the package has been built once).

@theobat
Copy link

theobat commented Dec 19, 2023

As a small addition, since we don't have component based builds yet, it's likely to overbuild/overwork frequently to "apply whatever you asked me to do to all the libraries (main or sub)"

@michaelpj
Copy link
Collaborator

Does that mean we can now close this issue?

@theobat
Copy link

theobat commented Jan 16, 2024

Yes, but the stack version supporting this is not released yet (although it should be released soon), for anyone interested in this issue you can track the relevant stack release at commercialhaskell/stack#6397

@fendor fendor closed this as completed Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build tool: stack status: blocked Not actionable, because blocked by upstream/GHC etc.
Projects
None yet
Development

No branches or pull requests

5 participants