-
Notifications
You must be signed in to change notification settings - Fork 61
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
Bugfix: don't mangle GHC options that begin with "-i" (e.g. "-instantiated-with") #157
Conversation
The 'fixImportDirs' function is supposed to target the "-i" option, but inadvertently also gets options such as "-instantiated-with" and "-ignore-package" that begin with "-i" (and changes them to e.g. "-i/Users/foo/stantiated-with"). This patch fixes that.
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.
Thank you for catching this!
Is there a reason why you are matching by prefix instead of elem
?
I use That deserves a comment, so I'll add one. |
Also refactor a little to place the comment in such a way that it doesnt' harm readability.
Do you think there is a more general solution? This requires that we update hie-bios for every ghc version that adds a new flag beginning with |
Sure, I suppose so! I guess I imagined that ghc's flags don't change that often. One way to solve this more generally would be to do this fixing of import paths after GHC parses its command line arguments—i.e. modifying the Another way would be to check, for each argument that looks like Upon further thought, I like the first option better. GHC already knows how to parse its own command line arguments – no need for us to try to do it ourselves. It looks like we modify the If that sounds good to you, I'm happy to implement it. |
The problem with the first approach is that previously, it was possible to pass around the raw compilation flags and they could be easily used. We would lose this property if the paths to I thought about the second approach as well, but I feel it is a bit too brittle. Unless the tools guarantee that the paths exist relative to the working directory. @mpickering Do you have a preference or idea how to properly handle this? |
Ah, I see. Relating to your second point, when I was playing around with it the other day, I thought of adding a field to ComponentOptions to pass the directory to initSession. But that’s immaterial if it’s desirable to be able to pass around the raw compilation flags.
… Am 02.03.2020 um 07:01 schrieb fendor ***@***.***>:
The problem with the first approach is that previously, it was possible to pass around the raw compilation flags and they could be easily used. Moreover, I fear that think that we can not easily know the root of the project, in initSession. I would have to verify, but I think that the flags are relative to the root of a cradle and cradles can be nested, thus getCurrentDirectory would be wrong, it would require that we pass in the Cradle to initSession.
I thought about the second approach as well, but I feel it is a bit too brittle. Unless the tools guarantee that the paths exist relative to the working directory.
@mpickering Do you have a preference or idea how to properly handle this?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
The way to fix this probably is to allow each |
@parsonyorick Sorry for not returning earlier to this issue. I have a prototype of the suggested implementation at #166 which ought to solve the problem by normalising the filepaths after GHC flag parsing |
Great, the approach at #166 makes complete sense to me—that will do the trick. |
Closed in favour of #166 |
The 'fixImportDirs' function inadvertently catches GHC options that begin with "-i", such as "-instantiated-with" and "-ignore-package", and changes them to e.g. "-i/Users/foo/stantiated-with". This patch fixes that.
This bit me when I was trying to use ghcide with a Cabal package that has two module signatures:
BaseMonad.hsig
andList.hsig
. I would get this error:This error occurred because Cabal was trying to pass
instantiated-with BaseMonad=<BaseMonad>,List=<List>
to GHC, butfixImportDirs
had turned that into-i/Users/parsonyorick/…/nstantiated-with BaseMonad=<BaseMonad>,List=<List>
, which GHC parsed as two commandline arguments.