haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Hackage build failure

Open andy-bell101 opened this issue 2 years ago • 13 comments

Your environment

Which OS do you use? ArchLinux Which version of GHC do you use and how did you install it? 9.0.2 from ghcup How is your project built (alternative: link to the project)? N/A

Which LSP client (editor/plugin) do you use? N/A Which version of HLS do you use and how did you install it? 1.8.0.0 attempted to compile via ghcup Have you configured HLS in any way (especially: a hie.yaml file)? No

Steps to reproduce

I can reproduce the issue locally using ghcup compile hls --version 1.8.0.0 --ghc 9.0.2. Seems like hackage is trying to build for ghc 9.2.4 but it's getting the same error messages.

Expected behaviour

It should build.

Actual behaviour

It doesn't build due to unresolvable dependencies.

Debug information

The build log on hackage can be found here https://hackage.haskell.org/package/haskell-language-server-1.8.0.0/reports/2, and I get the same error log on my local machine via ghcup

andy-bell101 avatar Sep 17 '22 11:09 andy-bell101

I think you should paste the build error here

juhp avatar Sep 17 '22 11:09 juhp

cabal: Could not resolve dependencies:
[__0] trying: haskell-language-server-1.8.0.0 (user goal)
[__1] trying: haskell-language-server:+qualifyimportednames
[__2] trying: hls-qualify-imported-names-plugin-1.0.1.0 (dependency of
haskell-language-server +qualifyimportednames)
[__3] next goal: hls-plugin-api (dependency of haskell-language-server)
[__3] rejecting: hls-plugin-api-1.5.0.0 (conflict:
hls-qualify-imported-names-plugin => hls-plugin-api^>=1.3 || ^>=1.4)
[__3] rejecting: hls-plugin-api-1.4.0.0 (conflict: haskell-language-server =>
hls-plugin-api^>=1.5)
[__3] skipping: hls-plugin-api-1.3.0.0, hls-plugin-api-1.2.0.2,
hls-plugin-api-1.2.0.1, hls-plugin-api-1.2.0.0, hls-plugin-api-1.1.0.2,
hls-plugin-api-1.1.0.1, hls-plugin-api-1.1.0.0, hls-plugin-api-1.0.0.0,
hls-plugin-api-0.7.1.0, hls-plugin-api-0.7.0.0, hls-plugin-api-0.6.0.0,
hls-plugin-api-0.5.0.1, hls-plugin-api-0.5.0.0, hls-plugin-api-0.4.1.0,
hls-plugin-api-0.4.0.0 (has the same characteristics that caused the previous
version to fail: excluded by constraint '^>=1.5' from
'haskell-language-server')
[__3] fail (backjumping, conflict set: haskell-language-server,
hls-plugin-api, hls-qualify-imported-names-plugin)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: haskell-language-server,
hls-plugin-api, haskell-language-server:qualifyimportednames,
hls-qualify-imported-names-plugin
Try running with --minimize-conflict-set to improve the error message.

andy-bell101 avatar Sep 17 '22 11:09 andy-bell101

Okay I came back with the exact same error (broken pieces) ;-)

I tried with cabal install --allow-newer, but that causes hiedb to fail with algebraic-graphs-0.7... Maybe hls-qualify-imported-names-plugin needs to be tweaked.

juhp avatar Sep 17 '22 12:09 juhp

Actually hls-qualify-imported-names-plugin.cabal here in git allows 1.5 but not the one in Hackage - seems there is some discrepancy?

juhp avatar Sep 17 '22 12:09 juhp

I think the simplest workaround may be to disable the qualifyImportedNames flag. Or one could try adding git hls-qualify-imported-names-plugin to a local cabal.project file perhaps.

Erm maybe not - seems hls-stylish-haskell-plugin also expects <1.5.... Maybe the only easy way to build currently is from git...

juhp avatar Sep 17 '22 12:09 juhp

Actually that might be mostly it: https://packdeps.haskellers.com/reverse/hls-plugin-api

juhp avatar Sep 17 '22 13:09 juhp

It looks like just revising those 2 plugins on Hackage for hls-plugin-api and ghcide would allow them to build for hls with cabal install.

However after that hls-hlint-plugin fails with:

Building library for hls-hlint-plugin-1.1.0.0..
[1 of 1] Compiling Ide.Plugin.Hlint ( src/Ide/Plugin/Hlint.hs, dist/build/Ide/Plugin/Hlint.o, dist/build/Ide/Plugin/Hlint.dyn_o )

src/Ide/Plugin/Hlint.hs:226:42: error:
    * Couldn't match expected type `SrcSpan'
                  with actual type `ghc-8.10.7:SrcLoc.SrcSpan'
      NB: `ghc-8.10.7:SrcLoc.SrcSpan'
            is defined in `SrcLoc' in package `ghc-8.10.7'
          `SrcSpan'
            is defined in `SrcLoc' in package `ghc-lib-parser-8.10.7.20220219'
    * In the second argument of `($)', namely `ideaSpan idea'
      In the `_range' field of a record
      In the expression:
        Diagnostic
          {_range = srcSpanToRange $ ideaSpan idea, _severity = Just DsInfo,
           _code = Just (InR $ T.pack $ codePre ++ ideaHint idea),
           _source = Just "hlint", _message = idea2Message idea,
           _relatedInformation = Nothing, _tags = Nothing}
    |
226 |             _range    = srcSpanToRange $ ideaSpan idea
    |                                          ^^^^^^^^^^^^^

src/Ide/Plugin/Hlint.hs:250:40: error:
    * Couldn't match expected type `SrcSpan'
                  with actual type `ghc-8.10.7:SrcLoc.SrcSpan'
      NB: `ghc-8.10.7:SrcLoc.SrcSpan'
            is defined in `SrcLoc' in package `ghc-8.10.7'
          `SrcSpan'
            is defined in `SrcLoc' in package `ghc-lib-parser-8.10.7.20220219'
    * In the first argument of `srcSpanToRange', namely `l'
      In the `_range' field of a record
      In the expression:
        Diagnostic
          {_range = srcSpanToRange l, _severity = Just DsInfo,
           _code = Just (InR "parser"), _source = Just "hlint",
           _message = T.unlines [T.pack msg, T.pack contents],
           _relatedInformation = Nothing, _tags = Nothing}
    |
250 |             _range    = srcSpanToRange l
    |                                        ^

src/Ide/Plugin/Hlint.hs:321:48: error:
    * Couldn't match type `Extension'
                     with `ghc-boot-th-8.10.7:GHC.LanguageExtensions.Type.Extension'
      NB: `ghc-boot-th-8.10.7:GHC.LanguageExtensions.Type.Extension'
            is defined in `GHC.LanguageExtensions.Type'
                in package `ghc-boot-th-8.10.7'
          `Extension'
            is defined in `GHC.LanguageExtensions.Type'
                in package `ghc-lib-parser-8.10.7.20220219'
      Expected type: [ghc-boot-th-8.10.7:GHC.LanguageExtensions.Type.Extension]
        Actual type: [Extension]
    * In the `enabledExtensions' field of a record
      In the second argument of `($)', namely
        `flags {enabledExtensions = hlintExts}'
      In a stmt of a 'do' block:
        return $ flags {enabledExtensions = hlintExts}
    |
321 |           return $ flags { enabledExtensions = hlintExts }
    |                                                ^^^^^^^^^

src/Ide/Plugin/Hlint.hs:338:5: error:
    * Couldn't match type `ghc-boot-th-8.10.7:GHC.LanguageExtensions.Type.Extension'
                     with `Extension'
      NB: `Extension'
            is defined in `GHC.LanguageExtensions.Type'
                in package `ghc-lib-parser-8.10.7.20220219'
          `ghc-boot-th-8.10.7:GHC.LanguageExtensions.Type.Extension'
            is defined in `GHC.LanguageExtensions.Type'
                in package `ghc-boot-th-8.10.7'
      Expected type: Action [Extension]
        Actual type: Action
                       [ghc-boot-th-8.10.7:GHC.LanguageExtensions.Type.Extension]
    * In a stmt of a 'do' block: return hscExts'
      In the expression:
        do dflags <- getFlags
           let hscExts = EnumSet.toList (extensionFlags dflags)
           let hscExts' = mapMaybe (readExtension . show) hscExts
           return hscExts'
      In an equation for `getExtensions':
          getExtensions nfp
            = do dflags <- getFlags
                 let hscExts = ...
                 let hscExts' = ...
                 ....
            where
                getFlags :: Action DynFlags
                getFlags
                  = do modsum <- use_ GetModSummary nfp
                       ....
    |
338 |     return hscExts'
    |     ^^^^^^^^^^^^^^^

src/Ide/Plugin/Hlint.hs:617:84: error:
    * Couldn't match type `ghc-8.10.7:SrcLoc.SrcSpan'
                     with `SrcSpan'
      NB: `SrcSpan'
            is defined in `SrcLoc' in package `ghc-lib-parser-8.10.7.20220219'
          `ghc-8.10.7:SrcLoc.SrcSpan'
            is defined in `SrcLoc' in package `ghc-8.10.7'
      Expected type: Idea -> SrcSpan
        Actual type: Idea -> ghc-8.10.7:SrcLoc.SrcSpan
    * In the second argument of `(.)', namely `ideaSpan'
      In the second argument of `(.)', namely `toRealSrcSpan . ideaSpan'
      In the expression:
        (srcSpanStartLine &&& srcSpanStartCol) . toRealSrcSpan . ideaSpan
    |
617 |                 ideaPos = (srcSpanStartLine &&& srcSpanStartCol) . toRealSrcSpan . ideaSpan
    |                                                                                    ^^^^^^^^
cabal: Failed to build hls-hlint-plugin-1.1.0.0 (which is required by
exe:haskell-language-server from haskell-language-server-1.8.0.0 and
exe:haskell-language-server-wrapper from haskell-language-server-1.8.0.0). See
the build log above for details.

juhp avatar Sep 17 '22 14:09 juhp

For now your build from git approach seems to be working. I'd like to help out but I don't really feel like I understand cabal/stack/ghcup all that well at this point. I'll do some research and hopefully I'll have something useful to add soon

andy-bell101 avatar Sep 17 '22 18:09 andy-bell101

The hls-hlint-plugin in Hackage and git seems the same, so it seems to be some kind of dependency issue, though I am wondering how it is possible to build.

juhp avatar Sep 18 '22 08:09 juhp

Okay with the final workaround - disabling the hlint plugin - I could build 1.8.0.0 for Fedora ghc-8.10.7 (it does build with ghc-9.0, though not ghc-9.2).

https://download.copr.fedorainfracloud.org/results/petersen/haskell-language-server/fedora-rawhide-x86_64/04843979-haskell-language-server/haskell-language-server.spec

juhp avatar Sep 18 '22 08:09 juhp

Check out our cabal.project file: hlint needs to be built with the ghc-lib flag. This flag has been turned on by default in HEAD but not yet in a Hackage release

pepeiborra avatar Sep 18 '22 12:09 pepeiborra

Actually hls-qualify-imported-names-plugin.cabal here in git allows 1.5 but not the one in Hackage - seems there is some discrepancy?

Fixed, thank you!

pepeiborra avatar Sep 18 '22 13:09 pepeiborra

Can you please also revise https://hackage.haskell.org/package/hls-stylish-haskell-plugin ?

juhp avatar Sep 20 '22 10:09 juhp

@pepeiborra did you do the revision or does that still need to happen?

michaelpj avatar Nov 02 '22 12:11 michaelpj

I don't remember now, looks like I didn't

pepeiborra avatar Nov 02 '22 12:11 pepeiborra

Revised.

michaelpj avatar Dec 14 '22 10:12 michaelpj

I wanted to check the status of this so I ran some tests:

haskell-language-server 1.9.0.0 as on hackage builds ok on GHC 9.2.5 and GHC 9.0.2 but not GHC 8.10.7 with the same hls-hlint-plugin failure note above. Note that, with all three compilers, the plan includes hls-hlint-plugin-1.1.1.0 and not hls-hlint-plugin-1.1.0.0 as above.

Edit: I ended up breaking the above links. That's my bad.

andreabedini avatar Jan 24 '23 03:01 andreabedini

Surprisingly enough hls-hlint-plugin-1.1.1.0 by itself compiles on GHC 8.10.7, so clearly something is broken.

I notice that in the above build hlint is bringing in ghc-lib-parser-9.2.5.20221107 while compiling on GHC 8.10.7, while the build failure (still on GHC 8.10.7) happens with ghc-lib-parser-8.10.7.20220219

Edit: well this is because hlint just declares a dependency on ghc-lib-parser so cabal will pick the newest version it can.

Edit: I ended up breaking the above links. That's my bad.

andreabedini avatar Jan 24 '23 04:01 andreabedini

Old and hopefully dead

michaelpj avatar Jan 16 '24 18:01 michaelpj