首页 > 解决方案 > opam init 失败 - 无法创建临时文件

问题描述

我在 Linux Virtualbox VM 上安装了 opam 2.1.0。当我尝试opam init时,我收到以下错误:

<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[ERROR] Could not update repository "default": OpamDownload.Download_fail(_, "Curl
        failed: \"/snap/bin/curl --write-out %{http_code}\\\\n --retry 3
        --retry-delay 2 --user-agent opam/2.1.0 -L -o
        /tmp/opam-32196-d33843/index.tar.gz.part --
        https://opam.ocaml.org/index.tar.gz\" exited with code 23")
[ERROR] Initial download of repository failed.

使用 --disable-sandboxing 运行没有帮助。我知道创建/写入/tmp/opam-...目录是一个问题,因为如果我用当前目录或主目录替换它,则命令本身运行良好。如果我在 curl 中使用 --create-dirs 选项,它也可以正常运行,/tmp/opam-...但我没有任何方法可以让 opam init 使用该选项。有任何想法吗?

谢谢

标签: opam

解决方案


更新

对我来说失败的原因opam init是因为 curl 在我的系统上安装了 snap。这正是您的虚拟机正在发生的事情。尝试运行opam init -verbose,这可能会揭示更多关于您遇到错误的原因。就我而言,我需要使用 opam 安装其他东西,但每次都失败。就这样snap uninstall curl,然后sudo apt install curl修复了一些事情。(只有在我教授的帮助下才能解决这个问题)

解决方法

我遇到了同样的问题,我在 OCaml 论坛上找到了解决方法:here。(归功于 UnixJunkie)

你可以运行:

opam init github git+https://github.com/ocaml/opam-repository.git

这应该避免证书问题。这对我有用。

我也尝试使用此答案解决证书问题。您可以尝试这样做,但是当解决方法是直接将其指向 github 存储库时,它似乎很复杂。

这个问题与这个问题类似


推荐阅读