-
Notifications
You must be signed in to change notification settings - Fork 1
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
Use cabal-helper 1.0 #26
Conversation
ea2f97b
to
cf23e26
Compare
Were there any changes needed inside the cabal-helper submodule after updating it to 1.0? |
@bubba no, this is just the submodules and the cradle type of cabal-helper-helper is taken from https://github.com/wz1000/cabal-helper-helper/blob/master/Main.hs |
cf23e26
to
ed9bf88
Compare
I had to add
to |
Maybe you are already aware but just in case:
Install it with |
b7c6e2f
to
ebb5b44
Compare
hi! trying to build it with cabal or stack in windows i've got an error in the solver due to a too restrictive lower bound on
i had to relax the lower bound of cabal-helper to the version used by the older ghc (8.2.2) used by hie:
|
Opened a pr to relax the lower bound upstream DanielG/cabal-helper#81 |
When testing with a simple cabal project, NOTE: It happened due a cabal 3.0.0.0 executable version built from source without the patch that fixed that behaviour |
Changin my cabal in $PATH to
|
Needs review and a bit more Documentation. |
2279cf2
to
8c3ff68
Compare
-- | Given a FilePath, find the Cradle the FilePath belongs to. | ||
-- | ||
-- TODO: document how and why this works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, i am trying to know where the project build is triggered with no luck 😄
See #26 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line packages <- runQuery projectPackages env
initialises the project contexts, e.g. configures projects enough such that we know the different packages in a project.
It produces the output one can see from HieWrapper.hs. However, afaik, this does not actually compile anything, I think it is only the configure step.
Actual compilation of the different units, e.g. library, executable happens on cradle basis: unitInfos_ <- mapM (\unit -> runQuery (unitInfo unit) env) units
Which should not compile the unit but download all dependencies and so, such that we know the targets in that unit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is possible that cabal-helper is running the cabal build --dry-run
shown in the logs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But hie is passing the unitId
to cabal-helper
and it can be the cause of errors with components with the same name, maybe we should prefix it with the package name (not sure what field would give us it), to avoid ambiguities
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is possible that cabal-helper is running the cabal build --dry-run shown in the logs?
It is, but I dont know to be honest. I am just using the High-Level API.
But hie is passing the unitId to cabal-helper and it can be the cause of errors with components with the same name, maybe we should prefix it with the package name (not sure what field would give us it), to avoid ambiguities
We are simply passing Units that have been obtained from a Package. Unless I am overlooking something, I feel like this is rather a minor bug of c-h.
Thank you for thorough analysis, investigative questions and constructive feedback!
I think the actual version could work in most cases, but for cabal based projects, could we get the compiler configured for build the project from cabal configuration ( |
@fendor it seems the projects builds are triggered by before calling So this seems to be the origen of the errors when components from different subpackages have the same name (like dhall) |
Hi! |
@jneira I think you can open a PR straight to |
Not sure if it is expected but if i open vscode in a simple project with a The vscode output shows:
and the Opening it with hie master behaves correctly. Deleting |
@jneira the error seems to be coming from the stack-test component whereas c-h is trying to (correctly) PS: @fendor you're lucky @dxld notifications also end up in my inbox :P |
Oh, now I understand, it is about the order the units are queried! If the test unit is queried before the library, it will fail since the dependencies won't compile! OK, great, we can handle that, actually, I think! @DanielG Haha, I didn't really want to tag you, I planned asking you in IRC about it! |
Great! in my case i had not opened in the editor any file of the exe or test component, only the lib file with the compile error. I thought it wouldn't even try to open it. |
|
||
[submodule "submodules/ghc-mod"] | ||
path = submodules/ghc-mod | ||
# url = https://github.com/arbor/ghc-mod.git | ||
url = https://github.com/alanz/ghc-mod.git | ||
# url = https://github.com/bubba/ghc-mod.git | ||
url = https://github.com/fendor/ghc-mod.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can eventually move ghc-project-types
into another location if needed, possibly into hie itself.
isStackCradle = (`elem` ["stack", "Cabal-Helper-Stack", "Cabal-Helper-Stack-None"]) | ||
. BIOS.actionName | ||
. BIOS.cradleOptsProg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like a really hacky way to work out if it is a stack cradle. I know hie-bios
is intended to be low level and unconstrained to allow easy extension, but perhaps we should ask for certain common flags to be set indicating whether it is stack, or make the actionName
a sum type identifying the well-known built-in hie-bios variants, and then have a constructor explicitly identifying that it is not one of those.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can not make actionName
a sum type, because then we can not add a cradle that hie-bios doesnt know about, like in this case "Cabal-Helper-Stack", except by adding a custom constructor such as Other String
, which in my opinion defeats the purpose of it.
I talked to @mpickering to add predicates upstream that hide this string check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason this check is to hack around two things.
- The options that the "stack" cradle from hie-bios doesn't really return the correct options. So there is a hack to add an additional target.
- The cradle doesn't specify the version of GHC which is expected to be used to compile a project. For a cabal project we could just configure the project with the correct version of GHC (the one which was used to build that specific version of HIE) but that wouldn't work for stack projects which are locked to a specific compiler version.
So if we fix both of these things we can also remove this check. That seems like a better long term solution.
-- | ||
-- Utility functions to manipulate FilePath's | ||
-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be wise to build these up from the primitives in https://hackage.haskell.org/package/filepath, which take cognizance of platform differences, and are battle tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually opened an issue upstream (haskell/filepath#73) to add these functions to filepath
, because I did not find a way to express them with the given API easily.
They are based on filepath
, though.
We have to find out to which unit a Module belongs to. To find it out, we have to configure each unit, which builds the dependencies, and see if it defines the given Module. If it does, we found our unit and can continue, however, if the test-unit, is queried first, for no particular reason, then it crashes. |
Hang on there. The order shouldn't matter. Cabal will just compile dependencies as needed. Can you give me some more context on what the problem you're having is? |
I am referring to the code in https://github.com/mpickering/haskell-ide-engine/pull/26/files#diff-8134e86af784446400558bb3cbfe7dcfR387 |
-- Intended usage: | ||
-- | ||
-- >>> isFilePathPrefixOf "./src/" "./src/File.hs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. We should run doctests in CI.
Just yaml -> fixCradle <$> BIOS.loadCradle yaml | ||
Nothing -> cabalHelperCradle fp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this then replace logic in hie-bios for implicitly finding a cradle with cabal-helper instead? Presumably cabal-helper handles this better then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it does and in theory, yes it does.
The documentation is amazing for this patch 😲 I think we should merge it and deal with any fall out in subsequent PRs. Amazing work @fendor ! |
The issue described in #26 (comment) needs to be fixed, I would like to fix it before merge. The fix is simply catching exceptions in https://github.com/mpickering/haskell-ide-engine/pull/26/files#diff-8134e86af784446400558bb3cbfe7dcfR398 . |
Ok, once you are happy then just merge the branch in and then #40 as well. |
@jneira, the issue https://github.com/mpickering/haskell-ide-engine/pull/26/files#diff-8134e86af784446400558bb3cbfe7dcfR398 should be solved now! |
Introduces cabal-helper cradle.
HIE usesGhc Version is correctly discovered based on project type.ghc --version
to discover the projec ghc version. However, this is wrong for stack-based projects.cc, @bubba