-
Notifications
You must be signed in to change notification settings - Fork 684
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
Build-type Configure on Windows with all-numeric path segments causes sed failure #5386
Comments
I've reproduced this on AppVeyor using the script: With AppVeyor results available at: https://ci.appveyor.com/project/snoyberg/bug-network-ghc84 Note that, at the time of writing this, it failed for GHC 8.4.3, but succeeded for GHC 8.2.2. |
Note that, while this is a terrible approach, the following change does in fact fix the bug: diff --git a/Cabal/Distribution/Simple.hs b/Cabal/Distribution/Simple.hs
index e45c8312a..06da8d264 100644
--- a/Cabal/Distribution/Simple.hs
+++ b/Cabal/Distribution/Simple.hs
@@ -734,7 +734,9 @@ runConfigureScript verbosity backwardsCompatHack flags lbi = do
((intercalate spSep extraPath ++ spSep)++) $ lookup "PATH" env
overEnv = ("CFLAGS", Just cflagsEnv) :
[("PATH", Just pathEnv) | not (null extraPath)]
- args' = configureFile:args ++ ["CC=" ++ ccProgShort]
+ args' = map (map replace) $ configureFile:args ++ ["CC=" ++ ccProgShort]
+ replace '\\' = '/'
+ replace c = c
shProg = simpleProgram "sh"
progDb = modifyProgramSearchPath
(\p -> map ProgramSearchPathDir extraPath ++ p) emptyProgramDb |
I think there's a deeper bug here, possibly in the network's configure script that has been uncovered by a change in Cabal. I can reproduce the failure on Linux by building in a directory named '\9':
My guess is it's doing something like |
AFAICT, this was originally caused by af49513. Prior to this commit, the configure script was referenced by relative path, bypassing this issue. We can get back that prior behavior without losing the goal of current-directory indifference with: diff --git a/Cabal/Distribution/Simple.hs b/Cabal/Distribution/Simple.hs
index e45c8312a..514a5ef23 100644
--- a/Cabal/Distribution/Simple.hs
+++ b/Cabal/Distribution/Simple.hs
@@ -724,8 +724,6 @@ runConfigureScript verbosity backwardsCompatHack flags lbi = do
-- to ccFlags
-- We don't try and tell configure which ld to use, as we don't have
-- a way to pass its flags too
- configureFile <- makeAbsolute $
- fromMaybe "." (takeDirectory <$> cabalFilePath lbi) </> "configure"
let extraPath = fromNubList $ configProgramPathExtra flags
let cflagsEnv = maybe (unwords ccFlags) (++ (" " ++ unwords ccFlags))
$ lookup "CFLAGS" env
@@ -734,7 +732,7 @@ runConfigureScript verbosity backwardsCompatHack flags lbi = do
((intercalate spSep extraPath ++ spSep)++) $ lookup "PATH" env
overEnv = ("CFLAGS", Just cflagsEnv) :
[("PATH", Just pathEnv) | not (null extraPath)]
- args' = configureFile:args ++ ["CC=" ++ ccProgShort]
+ args' = "./configure":args ++ ["CC=" ++ ccProgShort]
shProg = simpleProgram "sh"
progDb = modifyProgramSearchPath
(\p -> map ProgramSearchPathDir extraPath ++ p) emptyProgramDb
@@ -743,7 +741,7 @@ runConfigureScript verbosity backwardsCompatHack flags lbi = do
case shConfiguredProg of
Just sh -> runProgramInvocation verbosity $
(programInvocation (sh {programOverrideEnv = overEnv}) args')
- { progInvokeCwd = Just (buildDir lbi) }
+ { progInvokeCwd = fmap takeDirectory (cabalFilePath lbi) }
Nothing -> die notFoundMsg
where And it may be slightly blasphemous to say this, but it seems like this may in fact be a bug in |
@quasicomputational I agree with your analysis. However, I still think the fix for this should go into Cabal itself, see my previous comment (which I was writing concurrently with yours). |
I don't know autotools but I'd be slightly shocked (though maybe not surprised) to find that it didn't deal with the full range of POSIX paths. Preferring slashes to backslashes is sane, I think? I think your patch needs to be careful not to mangle a POSIX path like Some suspicious
Those files seem to have come straight from autotools, so a bug there is looking more and more likely. |
This is a workaround for haskell/cabal#5386 and #3944
Yeah, autotools bug. Here's the offending
|
I've sent a bug report to the autoconf people but we should probably also mitigate this in Cabal. The basic idea of Michael's patch is a good one; I'll try to make it robust and add some tests as well. |
Thanks for sending the bug report upstream, and isolating this further. Can you share the link to the bug report? |
autoconf doesn't seem to use a bug-tracker. This is the message I sent to their bug list. #5388 is where I'm hacking on the tests + fix but it's not baked yet; I've just realised how to test the doesn't-mangle-weird-POSIX-paths property, so that's next! |
On all platforms, warn about their presence. On Windows, we should use slashes (as opposed to backslashes) where possible, to avoid causing things like haskell#5386. Closes haskell#5386.
On all platforms, warn about their presence. On Windows, we should use slashes (as opposed to backslashes) where possible, to avoid causing things like haskell#5386. Closes haskell#5386.
If OP had invested a little bit of time to consult the GNU Autoconf manual instead, he might have saved himself some time by reading up on the filesystem limitations https://www.gnu.org/software/autoconf/manual/autoconf.html#File-System-Conventions, stating
|
Does this mean that |
On all platforms, warn about their presence. On Windows, we should use slashes (as opposed to backslashes) where possible, to avoid causing things like haskell#5386. Closes haskell#5386.
Work around haskell/cabal#5386 by setting the TMP env var
If that repro sounds far-fetched, let me justify it a bit: the temporary paths on AppVeyor look something like
c:\foo\bar\1\baz
, meaning that whenever using a temporary directory to unpack and build, say,network
, you get a build failure. Original issue: commercialhaskell/stack#3944.To repro:
c:\1
cd \1
cabal unpack network-2.7.0.0
cd network-2.7.0.0
runghc Setup.hs configure --user
When using Cabal 2.2, I get the output at the end:
Note that the
\1
changes based on the directory name chosen. I do not get a sed error for Cabal 2.0. I confirmed further that GHC 8.2.2 with its default-shipped Cabal (2.0) works, but upgrading to Cabal 2.2 does not.The text was updated successfully, but these errors were encountered: