opam - 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 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 存储库时,它似乎很复杂。
这个问题与这个问题类似。
推荐阅读
- php - 我无法从数据库中获取信息,从而无法在下拉列表中的一行上端到端显示
- javascript - 使表单更新在 vue 中更简洁
- matplotlib - 为子图设置一个公共颜色条
- css - 为什么 CSS 动画不会淡出?
- amazon-web-services - 为什么 AWS EMR 需要 2 个不同的安全组用于主节点和核心/任务节点?
- html - 如何使用 SWI Prolog 的 http/html_write 库将 HTML 写入文件
- kubernetes - Kubernetes:当创建一个新的 mutating webhook 时,如何将这个 Mutation 应用到集群中的现有资源?
- ruby-on-rails - Rails - has_many through、STI 和范围
- python-3.x - 是否可以不必为函数的每次迭代复制代码
- visual-studio - 地形的某些部分太暗