Repository navigation
Report a source directory that contains the search path separator - #12697
Open
swinilohani616-dot wants to merge 2 commits into
Open
swinilohani616-dot wants to merge 2 commits into
swinilohani616-dot wants to merge 2 commits into
Conversation
GHC splits every -i flag on the search path separator, and there is no way to escape it. So with a build directory like --builddir=foo:bar, GHC could not find the modules that Cabal generates in it, such as Paths_pkg. Stop before running GHC with an error that names the directory instead. Fixes haskell#12620.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12620.
If your build directory has a colon in it, like
--builddir=foo:bar, the build fails with a confusing error:The cause is that GHC splits every
-iflag on the search path separator (:on Unix,;on Windows), so-ifoo:bar/build/.../autogenbecomes two directories, and the modules Cabal generates there can't be found. Unfortunately Cabal can't work around this: GHC has no way to escape the separator, even in an absolute path, and passing the directories as separate-iflags doesn't help, because each one gets split the same way.So rather than letting GHC fail with that message, Cabal now stops before running GHC and tells you which directory is the problem:
I put the check in
ghcInvocation, since every GHC call goes through it, and it looks atghcOptSourcePath. That way it catches the problem wherever the directory comes from: the build directory,hs-source-dirs, or a project path. It usessearchPathSeparator, so on Windows it checks for;instead, and colons in drive letters aren't affected.I added a
cabal-testsuitetest,BuildDirSearchPathSeparator: a small package that usesPaths_pkg, built with a build directory containing the separator. It passes with this change and fails without it.