hid-examples icon indicating copy to clipboard operation
hid-examples copied to clipboard

Haskell Language Server does not work with the cabal configuration

Open dsame opened this issue 10 months ago • 1 comments

~/.ghcup/hls/2.9.0.1/lib/haskell-language-server-2.9.0.1/bin//haskell-language-server-9.10.1 --lsp

Failed to run ["cabal","v2-repl","~/s/hid-examples/intro/hello.hs"] in directory "~/s/hid-examples". Consult the logs for full command and error.
Failed command: cabal --builddir=~/.cache/hie-bios/dist-hid-examples-1a2b767487cc0fcd7c37dc9fd128706f v2-repl --with-compiler ~/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg ~/.cache/hie-bios/ghc-pkg-65d635035016d27a17cf27eb20540249 ~/s/hid-examples/intro/hello.hs

dsame avatar Apr 08 '25 15:04 dsame

Unfortunately, this seems to be a bug in Cabal. One workaround could be to delete all definitions of all the executables containing the if flag(with-pg) line from the hid-examples.cabal file. There are four such executables:

executable hasql
  other-modules:
      Paths_hid_examples
  autogen-modules:
      Paths_hid_examples
  ghc-options: -Wall -Werror -Wcompat -Widentities -Wincomplete-uni-patterns -Wincomplete-record-updates -Wno-unused-top-binds -Wno-orphans -Wno-error=unrecognised-warning-flags
  build-depends:
      base >=4.12 && <5
  default-language: Haskell2010
  if flag(with-pg)
    main-is: Main.hs
    other-modules:
        FilmInfo.Data
        Statements
        Sessions
        DBActions
    hs-source-dirs:
        ch15/hasql
        ch15
    build-depends:
        hasql >=1.3 && <1.7
      , hasql-th ==0.4.*
      , mtl >=2.0 && <2.4
      , profunctors >=5.3 && <5.7
      , text >=1.2 && <2.2
      , text-show >=3.0 && <4
      , vector >=0.11 && <0.14
  else
    main-is: empty/Main.hs
executable hdbc
  other-modules:
      Paths_hid_examples
  autogen-modules:
      Paths_hid_examples
  ghc-options: -Wall -Werror -Wcompat -Widentities -Wincomplete-uni-patterns -Wincomplete-record-updates -Wno-unused-top-binds -Wno-orphans -Wno-error=unrecognised-warning-flags
  build-depends:
      base >=4.12 && <5
  default-language: Haskell2010
  if flag(with-pg)
    main-is: hdbc.hs
    other-modules:
        FilmInfo.Data
    hs-source-dirs:
        ch15
    build-depends:
        HDBC >=2.3 && <2.5
      , HDBC-postgresql >=2.4 && <2.6
      , convertible >=1.0 && <1.2
      , text >=1.2 && <2.2
      , text-show >=3.0 && <4
  else
    main-is: empty/Main.hs
executable opaleye
  other-modules:
      Paths_hid_examples
  autogen-modules:
      Paths_hid_examples
  ghc-options: -Wall -Werror -Wcompat -Widentities -Wincomplete-uni-patterns -Wincomplete-record-updates -Wno-unused-top-binds -Wno-orphans -Wno-error=unrecognised-warning-flags
  build-depends:
      base >=4.12 && <5
  default-language: Haskell2010
  if flag(with-pg)
    main-is: Main.hs
    other-modules:
        FilmInfo.Data
        FilmInfo.FromField
        Tables
        Queries
        DBActions
    hs-source-dirs:
        ch15/opaleye
        ch15
    build-depends:
        bytestring >=0.10 && <0.13
      , opaleye >=0.8 && <0.11
      , postgresql-simple >=0.5 && <0.7
      , product-profunctors ==0.11.*
      , profunctors >=5.3 && <5.7
      , text >=1.2 && <2.2
      , text-show >=3.0 && <4
  else
    main-is: empty/Main.hs
executable pg-simple
  other-modules:
      Paths_hid_examples
  autogen-modules:
      Paths_hid_examples
  ghc-options: -Wall -Werror -Wcompat -Widentities -Wincomplete-uni-patterns -Wincomplete-record-updates -Wno-unused-top-binds -Wno-orphans -Wno-error=unrecognised-warning-flags
  build-depends:
      base >=4.12 && <5
  default-language: Haskell2010
  if flag(with-pg)
    main-is: pg-simple.hs
    other-modules:
        FilmInfo.Data
        FilmInfo.FromField
    hs-source-dirs:
        ch15
    build-depends:
        bytestring >=0.10 && <0.13
      , postgresql-simple >=0.5 && <0.7
      , text >=1.2 && <2.2
      , text-show >=3.0 && <4
  else
    main-is: empty/Main.hs

bravit avatar Apr 12 '25 17:04 bravit