使用 cabal 更新 agda 时出现内存不足情况错误?

Out-of-memory condition error when updating agda with cabal?

我正在尝试升级 agda,出现内存错误。有什么办法可以解决这个问题?

我尝试了 cabal install --ghc-options="+RTS -M600M" --force-reinstalls agda 但是根据类似的问题,这只是给出了一个堆错误。

wmacmil@w:~$ cabal install --force-reinstalls agda
Resolving dependencies...
Warning: The following packages are likely to be broken by the reinstalls:
Agda-2.6.0.1
Continuing even though the plan contains dangerous reinstalls.
Downloading base-compat-0.10.5...

...

[325 of 369] Compiling Agda.TypeChecking.IApplyConfluence ( src/full/Agda/TypeChecking/IApplyConfluence.hs, dist/build/Agda/TypeChecking/IApplyConfluence.o )
[326 of 369] Compiling Agda.TypeChecking.Rules.LHS.Unify ( src/full/Agda/TypeChecking/Rules/LHS/Unify.hs, dist/build/Agda/TypeChecking/Rules/LHS/Unify.o )
cabal: Leaving directory '/tmp/cabal-tmp-30263/Agda-2.6.1'
cabal: Error: some packages failed to install:
Agda-2.6.1 failed during the building phase. The exception was:
ExitFailure (-9)
This may be due to an out-of-memory condition.

啊,GHC 的内存饥饿是无法饱和的...

对于更大的安装,我通常做的是,几乎不限制 GHC 的 -M(或者可能是总内存的 80%),但确保它实际上具有每个进程的所有可用空间,通过限制编译为单个进程。

cabal install --ghc-options="+RTS -M7G" -j1 --force-reinstalls agda

显然,这会使一切变得非常缓慢,但至少它通常会成功。