-
Notifications
You must be signed in to change notification settings - Fork 63
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
Expose location of the ghc libdir in cradle. #151
Comments
Exposing the path to the executable could be confusing though, when Cradle starts to abstract more compilers than just |
I'd rather hie-bios deals with it as things like Nix change the result based on environment variables, which I'm hoping you will get right! |
Any consense on how to solve this? |
This would be very useful indeed. My understanding is that libdir and path to binary are equivalent. You can find the libdir from the binary, and viceversa. So it doesn't really matter, and if the libdir is more general, that's probably the right choice |
I think we can use |
Pretty sure this does not work unless the project has been already configured. Would the proposed API make sense for you? |
I tested it on a clean project and it looks to be implicitly configuring the project beforehand, this is with cabal-install 3.2.0.0. The proposed API looks good though, makes much more sense than when where I put it (inside componentoptions). Something like data CradleAction a = CradleAction {
actionName :: ActionName a
, runCradle :: LoggingFunction -> FilePath -> IO (CradleLoadResult ComponentOptions)
, getGhcPath :: IO (Maybe FilePath)
}
getGhcLibDir :: Cradle a -> IO FilePath |
Ugh just tested this on Linux, cabal-install 3.0.0 and got this strange bug
We can fix it by just creating a temporary directory though. Does this still happen on 3.2.0.0? |
Just tested, this is fixed on |
If the libdir becomes first-class, it would be nice if its location could be customized. |
I was wondering about ghcjs. Do we have to worry/think about it in the design of the API? |
@hyperfekt in #207, the location can be customised with the |
@bubba Unfortunately not, because that environment variable cannot change after the language server is started. The entire idea is changing the libdir between restarts. |
Implemented by #207 |
@hyperfekt Does #215 semi-cover your use case? i.e. having the ability to call a separate bios program to return the libdir so it can be changed on the fly? |
@bubba Yeah, that would definitely do it! |
Based on https://github.com/digital-asset/ghcide/issues/387#issuecomment-581151178, think about an API to obtain the libdir for a given Cradle.
First idea: Extend the cradle definition to query for the libdir, e.g:
(location of the function
getLibdir
, as well as name, is subject to bikeshedding)Currently, the default implementation for most cradles, except stack, would just call
ghc --print-libdir
while stack could callstack exec -- ghc --print-libdir
. Forcabal
, we could do something similar.A more generalized implementation could be to not expose a function to obtain the libdir but rather the path to the ghc version to use itself. Then other useful functions could be implemented with ease in application code, such as obtaining the ghc version to use in a cradle.
The text was updated successfully, but these errors were encountered: