-
Notifications
You must be signed in to change notification settings - Fork 698
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
Windows build failure building gi-cairo from haskell-gi #6782
Comments
Hi , i am trying to reproduce the error in my windows 10 using msys2, following the instructions of the package. To get the bindings
How do you genereated the bindings (gi-cairo and/or the other ones)? i've not found nothing in docs. |
Hi, and thanks for looking into this! The For instance, if I put the following into {-# LANGUAGE OverloadedStrings, OverloadedLabels #-}
{- cabal:
build-depends: base, haskell-gi-base, gi-gtk == 3.0.*
-}
import qualified GI.Gtk as Gtk
import Data.GI.Base
main :: IO ()
main = do
Gtk.init Nothing
win <- new Gtk.Window [ #title := "Hi there" ]
on win #destroy Gtk.mainQuit
button <- new Gtk.Button [ #label := "Click me" ]
on button #clicked (set button [ #sensitive := False,
#label := "Thanks for clicking me" ])
#add win button
#showAll win
Gtk.main and run |
Well i am still trying to install it looking in the issue tracker and reviewing the install instructions for win. It is a shot in the dark but with i've got weird error in windows in the past, not always obvious, due to the long path issue. I've observed you have the cabal |
After following closely the instructions in the wiki of the project i got to build gi-cairo (i tried inside a msys console and it failed, although i think it should work):
It worked with ghc-8.8.3 too. So maybe the path of |
I've ran the test script posted above too:
and a little window born! 😄 |
Thanks for looking into this @jneira! Changing
So it seems like one needs to set up the environment variables properly (although I am still unclear on what exactly is breaking if you don't). @georgefst Does this work for you too? |
@garetxe I was minutes away from posting the same discovery (unfortunately my Windows machine is incredibly slow and I'm still waiting for the build to fully complete, but it seems to be over the hurdles). Thanks @jneira ! I feel a bit silly for not setting the environment variables, but I think with the old Haskell Platform method it was clearer that they were needed. @Mistuke Is there any way that the chocolatey installer could set these, or at least prompt the user to do so? Seeing as they aren't specific to Anyway, I guess this isn't really a Cabal issue (aside from the lack of a useful error message). I did hit two seemingly unrelated ones while looking into this, but I'll report those separately... |
For reference, with PowerShell, the necessary commands were: $Env:PATH += ";C:\tools\msys64\usr\bin"
$Env:PATH += ";C:\tools\msys64\mingw64\bin"
$Env:XDG_DATA_DIRS = "C:\tools\msys64\mingw64\share"
$Env:PKG_CONFIG_PATH = "C:\tools\msys64\mingw64\lib\pkgconfig" |
@georgefst @garetxe you are welcome! i took the env vars values from the official docs about installing it in windows: https://github.com/haskell-gi/haskell-gi/wiki/Using-haskell-gi-in-Windows |
Yes, the irony is that this all started with me suggesting updating those docs (issue). And then I forgot about the one part of them that remains useful. I've never been entirely sure about how all these things interact (I'm not really a Windows user), but my impression is that the majority of users of Haskell on Windows aren't supposed to know or care about MSYS/MinGW (e.g. with the chocolatey installer, there aren't even start menu shortcuts created for them), so I figured PowerShell instructions would make the most sense. |
> $Env:PATH += ";C:\tools\msys64\usr\bin"
> $Env:PATH += ";C:\tools\msys64\mingw64\bin" The problem is these are very dangerous things to do. You're exposing binaries and shared libraries with the same name but completely different ABIs. If you want to run msys2 tools you should use the mingw shell which isolates the paths or you should use cabal run. This isn't done to prevent cryptic errors when people copy dlls to these folders so they're "on their path". So there isn't one good solution here.
|
The old platform also wouldn't have set As for PATH. Changing a user's System Path to contain binaries compiled with a cygwin runtime and a old vc runtime and GHC's own one is rather funky. Chocolatey already adds these just not globally. I.e. cabal is able to find it so I can however add an option for if people want to globally modify their PATH. It's up to them to solve any issues though. |
Right, some good points there. We're basing this on some fairly old instructions, so it's possible that not all 4 of those changes were actually needed. I'll investigate that first. In particular, I'd hope that the additions to As for |
|
Just to avoid confusion: |
To be clear, I'm not opposed to adding these at all to the package. The only one i really don't want is the |
I just gave it a test, and the minimal set I need is $Env:PATH += ";C:\tools\msys64\mingw64\bin"
$Env:XDG_DATA_DIRS = "C:\tools\msys64\mingw64\share"
$Env:PKG_CONFIG_PATH = "C:\tools\msys64\mingw64\lib\pkgconfig" So it seems like we do need to set the path properly, at least partly. I am still not sure why. |
What's the error when you don't set PATH? |
I just put the a gist here. |
What's in the build log?
|
Thanks for taking a look. Here is what that says:
|
One thing I notice playing with this is that
But when I try to run it from powershell it fails silently: PS C:\Users\User> .\pkg-config.exe --version
PS C:\Users\User> Is there any way of making |
I tried doing the same thing in
|
I guess the question then is how to tell cabal to put these in the search path when linking the setup script. I tried adding a |
You shouldn't do that, that hides the actual error. the question is why does running
You shouldn't need to. The standard Windows path search includes the directory where the binary is. That's why the dlls where placed in So let's take a step back, why does |
If I run
What do you have in your |
For reference, here is what I see in powershell in a clean Windows 10 Virtual Machine: PS C:\Users\User> echo $env:PATH
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Users\User\AppData\Local\Microsoft\WindowsApps;;C:\Users\User\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\User\AppData\Roaming\cabal\bin;C:\ProgramData\chocolatey\lib\ghc\tools\ghc-8.10.1\bin;C:\tools\msys64;
PS C:\Users\User> |
Nothing Haskell related aside from GHC. I don't change paths for global tools. I'll in sandbox mode. |
OK, thanks a lot. Let me summarize what I know so far: The build failure is easy (if time-consuming) to reproduce. First, run these as admin in a fresh Windows 10 VM to set everything up:
Then, as an ordinary user, in
This will fail, with a bunch of dialogs of the form The missing libraries seem to be, for the most part, those required by Here is one guess about what is happening: the custom setup in |
As a check of the guess above, I copied the problematic dlls to (I am of course not suggesting that this is the right fix, I am just trying to see if what I am guessing above holds water.) |
OK, I think that the previous comments were on the right track. I made a much simpler test case, you can find it at https://github.com/garetxe/cabal-custom-setup. |
Ugh... custom setups are a can of worms.. @phadej any idea what's going on here? |
I don't know.
That sounds very weird. Sorry, but I cannot help here. |
I can install This means you don't need 2, 5 and 6.
I can then set these automatically as well if I install pkg-config. These are safe as they shouldn't interact with anything else. Any objections? If not I'll see if I can't have them in this weekend's nightliest to test. |
ok, I will take a look, but It will likely be end of next week.. I have some high priority tasks on GHC to round up first.. |
This would be great, thanks!
Sure, thanks a lot! Just to note: the minimal testcase in https://github.com/garetxe/cabal-custom-setup does not involve |
I've found that setting the environment variables only seems to work for me in cmd and not in powershell or the System Properties gui, otherwise the same exit code -1073741515 issue as above occurs. I had previously got a project building, running and working after reading through this thread and using cmd. (After this, I then created a new project, intending to reproduce the issue with the minimal amount of dependencies, but when I tried to build I ran into the same exit code -1073741515 issue again. This time I was on powershell, but it hadn't occured to me that this would be an issue. I went back to the original project (on powershell) and after running
I could not see anything wrong with my environment variables.
Remembering that things originally started working on cmd, I retried building there and. A dialogue box popped up saying:
This is exactly the dll relating to the GHC panic, but I can see that this dll is right there in Remembering that things only started working the first time after setting the environment variables in cmd, I tried that, then I had set previously set the environment variables via the System Properties>Advanced>Environment Variables, as well as setting them with the powershell commands suggested above (unsure as to whether both admin and non-admin powershell were tried), and as I showed, they were correct when echoed back to me in powershell. It is unclear to me why building failed. Is this expected behavior? |
A possible alternative could be set
unfortunately cabal v2 does not honour that option in the global config, only if it is in cabal.project or as cli option: #7404 |
@DrewFenwick i am afraid that several 8.8 and 8.10 versions has suffered from a bug in windows which make ghc fail with segfaults. |
That would be the correct one, as
|
Discussion here seems to stall. Any interest in this or should we close? |
Yeah, an interesting debug session but not sure if it is actionable |
I vote close. |
Thanks everyone, closing. Feel free to reopen or, better yet, open a new ticket. |
Sure. I haven't tested any of this in a while, but my personal reasons for caring about it disappeared about two years ago. I would be curious to know whether @garetxe is still bothered, as the maintainer of the relevant package. Or whether @Mistuke ended up upstreaming any fixes, as implied in #6782 (comment). |
Trying to build the
gi-cairo
package, usingghc-8.10.1
andcabal-3.2.0.0
from Chocolatey. Previously worked with the 8.6.5 Haskell Platform. Log here.Initially reported on the haskell-gi repo. The stuff about
pkg-config
there can probably be ignored - that looks like a red herring.We've run out of ideas really, as neither Cabal nor GHC seem to be outputting any useful error message.
The text was updated successfully, but these errors were encountered: