Use implicit-hie#178
Conversation
|
Fixed
|
| <|> (stackExecutable >> (Stack Nothing,) <$> stackWorkDir fp) | ||
| <|> ((Cabal Nothing,) <$> cabalWorkDir fp) | ||
|
|
||
| <|> (cabalExecutable >> cabalProjectDir fp >> cabalDistDir fp >>= cabal) |
There was a problem hiding this comment.
There is a major bug when I run this on the haskell-language-server repo hie-bios picks cabal before getting here. I tried changing the order so stack is first, but it picks before implicitConfig'
❯ rm -rf dist-newstyle
❯ stack build
❯ hie-bios debug src/Ide/Cradle.hs
Cradle failed to load
Exit Code: ExitFailure 1
Stderr: Failed to parse result of calling cabal
Resolving dependencies...
From https://github.com/Avi-D-coder/hie-bios
+ 6d95e03...63e6e56 master -> origin/master (forced update)
Previous HEAD position was b67ebfd Use single file hie-implicit
HEAD is now at 63e6e56 Use single file hie-implicit
Warning: Requested index-state2020-05-05T17:33:00Z is newer than
'hackage.haskell.org'! Falling back to older state (2020-05-02T22:21:20Z).
cabal: Could not resolve dependencies:
[__0] trying: ghcide-0.1.0 (user goal)
[__1] next goal: haskell-lsp-types (dependency of ghcide)
[__1] rejecting: haskell-lsp-types-0.21.0.0, haskell-lsp-types-0.20.0.0,
haskell-lsp-types-0.19.0.0, haskell-lsp-types-0.18.0.0,
haskell-lsp-types-0.17.0.0, haskell-lsp-types-0.16.0.0,
haskell-lsp-types-0.15.0.0, haskell-lsp-types-0.14.0.1,
haskell-lsp-types-0.14.0.0, haskell-lsp-types-0.13.0.0,
haskell-lsp-types-0.12.1.0, haskell-lsp-types-0.12.0.0,
haskell-lsp-types-0.11.0.0, haskell-lsp-types-0.10.0.0,
haskell-lsp-types-0.9.0.0, haskell-lsp-types-0.8.2.0,
haskell-lsp-types-0.8.0.1, haskell-lsp-types-0.8.0.0,
haskell-lsp-types-0.7.0.0, haskell-lsp-types-0.6.0.0,
haskell-lsp-types-0.5.0.0, haskell-lsp-types-0.4.0.0,
haskell-lsp-types-0.2.2.0, haskell-lsp-types-0.2.1.0,
haskell-lsp-types-0.15.0.1 (conflict: ghcide => haskell-lsp-types==0.22.*)
[__1] fail (backjumping, conflict set: ghcide, haskell-lsp-types)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: ghcide, haskell-lsp-types|
@mpickering @fendor @bubba @alanz |
|
I hope you dont mind i commented about:
|
|
@jneira Yes, There are a number of unsupported cases.
Stack is easy, but Cabal excepts craziness like this: |
|
To do This looks easier than I though since filepattern is very nice. |
|
Do you handle |
|
@fendor For now we require a cabal file, since stack build always creates one anyway. |
True, but |
|
Adding support for package.yaml is pretty simple since it's just YAML, but it's not on my imitate todo list.
|
|
@jneira Could you try it again it should be fixed. |
|
In the future we should check if a deeply nested cabal file is listed as stack.yaml or cabal.project package. Implicit-hie no longer erroneously adds them, but the logic at For example the From the haskell-language-server ❯ hie-bios debug install/src/Cabal.hs
Cradle failed to load
Exit Code: ExitSuccess
Stderr: Multi Cradle: No prefixes matched
pwd: /home/host/haskell-language-server
filepath: /home/host/haskell-language-server/install/src/Cabal.hs
prefixes:
("./src",Cabal {component = Just "lib:haskell-language-server"})
("./exe/Main.hs",Cabal {component = Just "haskell-language-server:exe:haskell-language-server"})
("./exe/Wrapper.hs",Cabal {component = Just "haskell-language-server:exe:haskell-language-server-wrapper"})
("./test/functional",Cabal {component = Just "haskell-language-server:test:func-test"})
("./test/utils",Cabal {component = Just "lib:haskell-language-server:hls-test-utils"})
("ghcide/src",Cabal {component = Just "lib:ghcide"})
("ghcide/src-ghc86",Cabal {component = Just "lib:ghcide"})
("ghcide/src-ghc88",Cabal {component = Just "lib:ghcide"})
("ghcide/src-ghc810",Cabal {component = Just "lib:ghcide"})
("ghcide/test/preprocessor/Main.hs",Cabal {component = Just "ghcide:exe:ghcide-test-preprocessor"})
("ghcide/exe/Main.hs",Cabal {component = Just "ghcide:exe:ghcide"})
("ghcide/test/cabal",Cabal {component = Just "ghcide:test:ghcide-tests"})
("ghcide/test/exe",Cabal {component = Just "ghcide:test:ghcide-tests"})
("ghcide/test/src",Cabal {component = Just "ghcide:test:ghcide-tests"})
From the haskell-language-server/install ❯ hie-bios debug src/Cabal.hs
Root directory: /home/host/haskell-language-server/install
Component directory: /home/host/haskell-language-server/install
GHC options: -fbuilding-cabal-package -O0 -outputdir /home/host/haskell-language-server/install/dist-newstyle/build/x86_64-linux/ghc-8.8.3/hls-install-0.8.0.0/build -odir /home/host/haskell-language-server/install/dist-newstyle/build/x86_64-linux/ghc-8.8.3/hls-install-0.8.0.0/build -hidir /home/host/haskell-language-server/install/dist-newstyle/build/x86_64-linux/ghc-8.8.3/hls-install-0.8.0.0/build -stubdir /home/host/haskell-language-server/install/dist-newstyle/build/x86_64-linux/ghc-8.8.3/hls-install-0.8.0.0/build -i -i/home/host/haskell-language-server/install/dist-newstyle/build/x86_64-linux/ghc-8.8.3/hls-install-0.8.0.0/build -isrc -i/home/host/haskell-language-server/install/dist-newstyle/build/x86_64-linux/ghc-8.8.3/hls-install-0.8.0.0/build/autogen -i/home/host/haskell-language-server/install/dist-newstyle/build/x86_64-linux/ghc-8.8.3/hls-install-0.8.0.0/build/global-autogen -I/home/host/haskell-language-server/install/dist-newstyle/build/x86_64-linux/ghc-8.8.3/hls-install-0.8.0.0/build/autogen -I/home/host/haskell-language-server/install/dist-newstyle/build/x86_64-linux/ghc-8.8.3/hls-install-0.8.0.0/build/global-autogen -I/home/host/haskell-language-server/install/dist-newstyle/build/x86_64-linux/ghc-8.8.3/hls-install-0.8.0.0/build -optP-include -optP/home/host/haskell-language-server/install/dist-newstyle/build/x86_64-linux/ghc-8.8.3/hls-install-0.8.0.0/build/autogen/cabal_macros.h -this-unit-id hls-install-0.8.0.0-inplace -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db /home/host/.cabal/store/ghc-8.8.3/package.db -package-db /home/host/haskell-language-server/install/dist-newstyle/packagedb/ghc-8.8.3 -package-db /home/host/haskell-language-server/install/dist-newstyle/build/x86_64-linux/ghc-8.8.3/hls-install-0.8.0.0/package.conf.inplace -package-id base-4.13.0.0 -package-id cabal-install-parsers-0.3.0.1-bf2c23a2e5f58aa31d88a36792451fe7eabe7b48962cf209167ab70e15b9edbe -package-id directory-1.3.6.0 -package-id extra-1.7.1-acdd3835354a9eb3db781548168efec45616130a72a342610f3c36ec5cf13211 -package-id filepath-1.4.2.1 -package-id shake-0.18.5-602f2cdbd3147204d88e77f8741bf241686d3245c138659b0f8f659103b171f2 -package-id text-1.2.4.0 -XHaskell2010 -XLambdaCase -XTupleSections -XRecordWildCards HlsInstall BuildSystem Stack Version Cabal Print Env Help -hide-all-packages
System libraries: /home/host/.ghcup/ghc/8.8.3/lib/ghc-8.8.3
Config Location: No explicit config found
Cradle: Cradle {cradleRootDir = "/home/host/haskell-language-server/install", cradleOptsProg = CradleAction: Cabal}
Dependencies: hls-install.cabal cabal.project cabal.project.local |
|
Even for complex configs like hls and hie this now generates the correct configs. Only common stanzas and conditionals are not supported. cradle:
cabal:
- path: "./src"
component: "lib:haskell-ide-engine"
- path: "./app/MainHie.hs"
component: "haskell-ide-engine:exe:hie"
- path: "./app/HieWrapper.hs"
component: "haskell-ide-engine:exe:hie-wrapper"
- path: "./test/utils"
component: "lib:haskell-ide-engine:hie-test-utils"
- path: "./test/unit"
component: "haskell-ide-engine:test:unit-test"
- path: "./test/dispatcher"
component: "haskell-ide-engine:test:dispatcher-test"
- path: "./test/plugin-dispatcher"
component: "haskell-ide-engine:test:plugin-dispatcher-test"
- path: "./test/functional"
component: "haskell-ide-engine:test:func-test"
- path: "./test/wrapper"
component: "haskell-ide-engine:test:wrapper-test"
- path: "./hie-plugin-api/./"
component: "lib:hie-plugin-api"
stack:
- path: "./src"
component: "haskell-ide-engine:lib"
- path: "./app/MainHie.hs"
component: "haskell-ide-engine:exe:hie"
- path: "./app/HieWrapper.hs"
component: "haskell-ide-engine:exe:hie-wrapper"
- path: "./test/utils"
component: "haskell-ide-engine:lib:hie-test-utils"
- path: "./test/unit"
component: "haskell-ide-engine:test:unit-test"
- path: "./test/dispatcher"
component: "haskell-ide-engine:test:dispatcher-test"
- path: "./test/plugin-dispatcher"
component: "haskell-ide-engine:test:plugin-dispatcher-test"
- path: "./test/functional"
component: "haskell-ide-engine:test:func-test"
- path: "./test/wrapper"
component: "haskell-ide-engine:test:wrapper-test"
- path: "hie-plugin-api/./"
component: "hie-plugin-api:lib" |
|
Looking good! So, then for the cabal-helper source, I assume it will break? It has common stanzas, overlapping source directories and conditions for stanzas. In depth review will come this week |
|
@fendor Yes, implicit-hie generates an incomplete multi cradle config for the cabal-helper repo. Although it seems to work better than the cabal-helper cradle under hie. cradle:
cabal:
- path: "./lib"
component: "lib:cabal-helper"
- path: "./tests"
component: "cabal-helper:test:compile-test"
- path: "./tests"
component: "cabal-helper:test:programs-test"
- path: "./tests"
component: "cabal-helper:test:ghc-session"
- path: "./tests"
component: "cabal-helper:test:examples"
- path: "./src/CabalHelper/Runtime/Main.hs"
component: "cabal-helper:exe:cabal-helper-main"
Broken file under cabal-helper working with the above config/this pr. With this PR's implicit cradle (no hie.yaml file written). |
|
Nice improvements! Not sure if it is possible (or it is already done) but could we rely in the actual implicit mechanism (cabal/stack repl file) if the file is not under a path in the multi cradle (or generally if implicit-hie fails to build the multi-cradle) |
|
@jneira I'm not quite sure what you mean. Could you elaborate or give an example? |
|
Mmm, sorry for my quircky english, i wanted to mean that i would continue using: <|> (stackExecutable >> (Stack Nothing,) <$> stackWorkDir fp)
<|> ((Cabal Nothing,) <$> cabalWorkDir fp)as the last resort in the implicit config (with the appropiate adjustements) in two cases:
|
|
@jneira good idea, I can't think of a reason why we couldn't do that. |
That is interesting, I remember that I tested that thoroughly when implementing the Cabal Helper cradle. |
|
I do not think I want to merge this patch. I would rather remove all the implicit cradle searching from hie-bios and leave that to external libraries such as your own. |
|
If that's the approach, it suggests we need a separate package hie-bios-implicit that wraps this one with magic implicitness, and then things like hls/ghcide would use that one. Or is another route the suggested one? |
|
@ndmitchell We're debating whether or not hls should use implict-hie or cabal-helper and in what order haskell/haskell-language-server#110 |
Replaces implicit cradle logic with implicit-hie.
changes default to cabal over stack, since stack cannot load a cradle with a type error.