I'm using Vagrant to build my Haskell Cabal project on Linux. When I cabal build
in the Vagrant VM, the binary that's produced is fine. When I try to script the build from the host machine using vagrant ssh -c 'cabal build'
a binary of zero size is produced. The compile clearly works but I think as soon as the linker kicks in, the Vagrant shell is closed and terminates the linking. Why would this be happening?
After some Googling I could only find one SO question that looked similar.
With some help from IRC, we were able to determine this works:
ssh [email protected] -p 2222 -i .vagrant.d/insecure_private_key 'cabal build'
Here's the ssh command vagrant ssh
dumps in debug mode which doesn't work:
["[email protected]", "-p", "2222", "-o", "Compression=yes", "-o", "DSAAuthentication=yes", "-o", "LogLevel=FATAL", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-o", "IdentitiesOnly=yes", "-i", ".vagrant.d/insecure_private_key", "-t", "bash -l -c 'pwd'"]
Using deduction I've found that the ssh -t
is causing the problem. From the docs:
-t Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine, which can be very useful, e.g. when implementing menu services. Multiple -t options force tty allocation, even if ssh has no local tty.
So now the question is why does -t
cause cabal build
to fail?
Running cabal build -v3
bails out with the error /usr/bin/ghc returned ExitFailure 9
which I think means out of memory.
The OOM is killing GHC when running out of memory. The ssh -t
flag was apparently just enough to put it over the threshold. Confirmed with /var/log/syslog
. The solution is to simply allocate more memory to the VM. Thanks to tibber and teukka on Freenode.