简体   繁体   English

Cabal安装标准内存不足

[英]Cabal install criterion out of memory

I'm running on a container with 768MB ram and 512 MB swap space.我在具有 768MB 内存和 512MB 交换空间的容器上运行。 I can't increase either of this.我不能增加这两个。 cabal install criterion always gives cabal install criterion总是给出

Failed during the building phase.
The exception was: ExitFailure (-9)
This may be due to an out-of-memory condition.

during Compiling Criterion.Types .Compiling Criterion.Types期间。 Is there any way around this or do I have to make do without criterion?有什么办法可以解决这个问题,还是我必须在没有标准的情况下凑合?

在GHC上设置RTS标志以限制其内存使用量( --ghc-options="+RTS -M600M" ),并避免并行运行多个作业( -j1 )。

Answer to @DavidAzar's comment on the answer:回答@DavidAzar 对答案的评论:

@Li-yaoXia's solution worked, but then I had more problems. @Li-yaoXia 的解决方案有效,但后来我遇到了更多问题。 This is all from my rough notes as I tracked my way through the problem.这一切都来自我在解决问题时的粗略笔记。 So there might be a more streamlined solution.所以可能有一个更精简的解决方案。

Well, actually it compiled everything, but cabal --version still says 2.4, not 3.4.好吧,实际上它编译了所有内容,但cabal --version仍然说 2.4,而不是 3.4。 Maybe it's not in the path?也许它不在路径中?

Warning: could not create a symlink in /root/.cabal/bin for cabal because 
the file exists there already but is not managed by cabal. You can create a symlink for 
this executable manually if you wish. The executable file has been installed at /root/.cabal/bin/cabal

There appears to be a solution here: https://stackoverflow.com/a/17030330/52236 But I have to figure out how to remove the existing symlink before redoing the cabal install and doing the recompile process all over again.这里似乎有一个解决方案: https ://stackoverflow.com/a/17030330/52236 但我必须弄清楚如何删除现有的符号链接,然后再重新安装 cabal 并重新进行重新编译过程。

There is also this solution here, which I will try first: updating cabal-install, but version is not changed这里也有这个解决方案,我先试试: update cabal-install, but version is not changed

  • Ran unminimize from bash, which installs all the normal stuff to ubuntu.从 bash 中unminimize ,它将所有正常的东西安装到 ubuntu。

  • First, in /bin, create a folder called /cabal-old, then copy the cabal executable to the cabal-old folder.首先,在 /bin 中,创建一个名为 /cabal-old 的文件夹,然后将 cabal 可执行文件复制到 cabal-old 文件夹中。 Then remove cabal from the /bin folder.然后从 /bin 文件夹中删除 cabal。

  • Then create a new symlink pointing to the new cabal executable:然后创建一个指向新 cabal 可执行文件的新符号链接:

    ln -s /root/.cabal/bin/cabal cabal ln -s /root/.cabal/bin/cabal cabal

  • This gets cabal 3.4 to show up when doing cabal --version.这让 cabal 3.4 在执行 cabal --version 时出现。

  • Next, install git: apt-get install git接下来,安装 git:apt-get install git

  • Then go to plutus-pioneer-program/code/week01/ folder and enter cabal build然后进入 plutus-pioneer-program/code/week01/ 文件夹并输入cabal build

  • This downloads a lot of stuff from git, and then fails.这从 git 下载了很多东西,然后失败了。

    Warning: Requested index-state 2021-02-24T00:00:00Z is newer than 'hackage.haskell.org'!警告:请求的索引状态 2021-02-24T00:00:00Z 比“hackage.haskell.org”更新! Falling back to older state (2021-02-23T23:53:53Z).回退到旧状态 (2021-02-23T23:53:53Z)。 Resolving dependencies...cabal: Could not resolve dependencies: [__0] trying: Win32-network-0.1.0.0 (user goal) [__1] trying: base-4.12.0.0/installed-4.12.0.0 (dependency of Win32-network) [__2] next goal: plutus-pioneer-program-week01 (user goal) [__2] rejecting: plutus-pioneer-program-week01-0.1.0.0 (conflict:base==4.12.0.0/installed-4.12.0.0, plutus-pioneer-program-week01 =>base^>=4.14.1.0) [__2] fail (backjumping, conflict set: base, plutus-pioneer-program-week01)解决依赖关系...cabal:无法解决依赖关系:[__0] 尝试:Win32-network-0.1.0.0(用户目标)[__1] 尝试:base-4.12.0.0/installed-4.12.0.0(Win32-network 的依赖关系)[__2]下一个目标:plutus-pioneer-program-week01(用户目标)[__2]拒绝:plutus-pioneer-program-week01-0.1.0.0(冲突:base==4.12.0.0/installed-4.12.0.0, plutus-pioneer-program-week01 =>base^>=4.14.1.0) [__2] 失败(回跳,冲突集:base,plutus-pioneer-program-week01)

    After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: base, Win32-network,plutus-pioneer-program-week01在彻底搜索了依赖树的其余部分之后,这些是我最难以实现的目标:base、Win32-network、plutus-pioneer-program-week01

  • I got a suggestion from someone on Stackoverflow that the Plutus-Pioneer code might need ghc 8.10, and I'm on a version of 8.6.5, so next step is to figure out how to update that.我从 Stackoverflow 上的某个人那里得到了一个建议,即 Plutus-Pioneer 代码可能需要 ghc 8.10,而我使用的是 8.6.5 版本,所以下一步是弄清楚如何更新它。

  • Before getting ghc 8.10, I apparently need to have ghcup installed, run this as non-root user?:在获得 ghc 8.10 之前,我显然需要安装 ghcup,以非 root 用户身份运行它?:

    curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

  • this started the install, but failed because I don't have 'make' installed.这开始了安装,但因为我没有安装“make”而失败。 Run this:运行这个:

    apt-get install make apt-get 安装

  • then re-run the curl command.然后重新运行 curl 命令。 The curl installer output shows ghc 8.10 being installed, but after it's done, ghc --version outputs 8.6.5 still. curl 安装程序输出显示正在安装 ghc 8.10,但完成后, ghc --version仍然输出 8.6.5。 Another symlink issue?另一个符号链接问题?

  • I found this issue in the output:我在输出中发现了这个问题:

    In order to run ghc and cabal, you need to adjust your PATH variable.为了运行 ghc 和 cabal,您需要调整 PATH 变量。 You may want to source '/root/.ghcup/env' in your shell configuration to do so (eg ~/.bashrc).您可能希望在您的 shell 配置中使用 source '/root/.ghcup/env' 来执行此操作(例如 ~/.bashrc)。

  • It also might require figuring out how to specify which version of ghc to use.它还可能需要弄清楚如何指定要使用的 ghc 版本。

  • I need to update the simlink in the bin folder in order to get the correct version of ghc being used, and there are the following other links to update:我需要更新 bin 文件夹中的 simlink 以获得正在使用的正确版本的 ghc,并且还有以下其他链接要更新:

lrwxrwxrwx 1 root root   9 Mar 24  2020 ghc -> ghc-8.6.5
-rwxr-xr-x 1 root root 226 Mar 24  2020 ghc-8.6.5  
lrwxrwxrwx 1 root root  13 Mar 24  2020 ghc-pkg -> ghc-pkg-8.6.5
-rwxr-xr-x 1 root root 258 Mar 24  2020 ghc-pkg-8.6.5  
lrwxrwxrwx 1 root root  10 Mar 24  2020 ghci -> ghci-8.6.5
-rwxr-xr-x 1 root root  55 Mar 24  2020 ghci-8.6.5

First, created a new symlink for ghcup:首先,为 ghcup 创建一个新的符号链接:

ln -s /root/.ghcup/bin/ghcup ghcup

(Although I can't remember what I needed ghcup for.) (虽然我不记得我需要 ghcup 做什么。)

  • Next, update the ghc symlinks for all 3 symlinks listed above in the /bin folder:接下来,更新 /bin 文件夹中上面列出的所有 3 个符号链接的 ghc 符号链接:

    mv -T ghc ghc-old-link ln -s /root/.ghcup/bin/ghc ghc mv -T ghc ghc-old-link ln -s /root/.ghcup/bin/ghc ghc

  • This works to get the newer version of ghc showing up in the bash shell.这有助于在 bash shell 中显示较新版本的 ghc。

  • Now trying to build, and it downloads and starts building a lot of stuff, but now this error happens:现在尝试构建,它下载并开始构建很多东西,但现在发生了这个错误:

    cabal: Failed to build cborg-0.2.4.0 (which is required by plutus-pioneer-program-week01-0.1.0.0). cabal:无法构建 cborg-0.2.4.0(这是 plutus-pioneer-program-week01-0.1.0.0 所要求的)。 The build process was killed (ieSIGKILL).构建过程被终止(即SIGKILL)。 The typical reason for this is that there is not enough memory available (eg the OS killed a process using lots of memory).造成这种情况的典型原因是没有足够的可用内存(例如,操作系统使用大量内存杀死了一个进程)。

Solution for this: Docker -> Preferences -> Resources -> increase RAM, and swap space.解决方案:Docker -> 首选项 -> 资源 -> 增加 RAM 和交换空间。 In my case from 2-8GB RAM, and from 1 to 2 GB swap space.在我的例子中,内存为 2-8GB,交换空间为 1 到 2GB。

Now it builds the Plutus Pioneer code for week 1.现在它为第 1 周构建 Plutus Pioneer 代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM