Vscode fails with Could not load module ‘Database.SQLite.Simple’ while HLS and cabal pass

110 Views Asked by At

I am trying to test writing a simple CRUD app in haskell. I installed the VSCode Haskell extension and it works for simple files, but for those imports in Main.hs I get an error:

import Database.SQLite.Simple
import Database.SQLite.Simple.FromRow

the error:

Could not load module ‘Database.SQLite.Simple’
It is a member of the hidden package ‘sqlite-simple-0.4.18.2’.
You can run ‘:set -package sqlite-simple’ to expose it.
(Note: this unloads all the modules in the current scope.)

my .cabal looks like this:

executable generate-hs
    main-is:          Main.hs

    other-modules:    HtmlGen

    build-depends:    
        base ^>=4.17.2.0,
        sqlite-simple ^>=0.4.18.2,
        scotty,
        aeson,
        time,
        text,
        blaze-html,
        blaze-markup

    hs-source-dirs:   app
    default-language: Haskell2010

running haskell-language-server passes, cabal run sets up a proper scotty instance the vscode extension is configured to use to look in ~/.ghcup

what I tried so far:
I tried adding ~/.ghcup to path and using that, same results
I tried restarting everything, same results
I installed sqlite-simple globally via cabal install --lib sqlite-simple, same results
looking in ghc-pkg but there is no sqlite-simple there

How can I solve this error? Where should I start debugging?

Any help appreciated

relevant versions:

Glasgow Haskell Compiler, Version 9.4.7
cabal-install version 3.6.2.0
compiled using version 3.6.2.0 of the Cabal librar
haskell-language-server version: 2.4.0.0 (GHC: 9.4.7) (PATH: /Users/someone/.ghcup/hls/2.4.0.0/lib/haskell-language-server-2.4.0.0/bin/haskell-language-server-9.4.7)
vscode extension: v2.4.1

appending based on comments: view (in vscode) -> haskell

2023-11-12T16:46:22.199302Z | Info | Live bytes: 334.59MB Heap size: 1419.77MB
[Error - 17:47:05] Request textDocument/foldingRange failed.
  Message: codeRange: Rule Failed: GetCodeRange
  Code: -32803 
[Error - 17:47:08] Request textDocument/foldingRange failed.
  Message: codeRange: Rule Failed: GetCodeRange
  Code: -32803 

current hie.yaml

cradle:
  cabal:
    component: "exe:generate-hs"

dependencies:
  - sqlite-simple
0

There are 0 best solutions below