我试图在 vscode 中使用 coq,但似乎无法使其工作。
错误:
Could not start coqtop (coqtop)
我得到这个选项:

令人费解,因为我的终端似乎知道 coq 在哪里:
(meta_learning) brandomiranda~/sketching-learning-coq ❯ coqc -v
The Coq Proof Assistant, version 8.14.1
compiled with OCaml 4.10.2
(meta_learning) brandomiranda~/sketching-learning-coq ❯ echo $PATH
/Users/brandomiranda/.opam/__coq-platform.2022.01.0~8.14~2022.01/bin:/Users/brandomiranda/opt/anaconda3/envs/meta_learning/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin
所以我的问题是:
- 如果我的终端可以很好地找到 coq,为什么当我打开 vscode 时会发生此错误?
- 我该如何解决这个问题?我需要设置什么路径以及为什么?
有人建议我这样做:
eval $(opam env); dirname $(which coqtop)
但它没有做任何事情,或者至少没有解决问题...
我确实复制粘贴:
/Users/brandomiranda/.opam/__coq-platform.2022.01.0~8.14~2022.01/bin
到 vscode 给我的提示,并且似乎已经修复了它,因为我的脚本被正确检查。然而,我发现这令人不安,因为我不知道它做了什么,也不知道为什么会起作用。
有人可以向我解释为什么这有效吗——特别是因为查看我的 PATH(上面打印的)coq 已经在全球范围内可用?
仅供参考,使用其平台安装脚本安装代码:https://github。 com/coq/platform/blob/main/doc/README_macOS.md 我想在这样做之后,上面的 PATH 将被更新为我从 vscode 复制粘贴到设置全局的正确内容。
相关:
I was trying to use coq in vscode but I can't seem to make it to work.
Error:
Could not start coqtop (coqtop)
I get this option:

which is puzzling since my terminal seems to know just fine where coq is:
(meta_learning) brandomiranda~/sketching-learning-coq ❯ coqc -v
The Coq Proof Assistant, version 8.14.1
compiled with OCaml 4.10.2
(meta_learning) brandomiranda~/sketching-learning-coq ❯ echo $PATH
/Users/brandomiranda/.opam/__coq-platform.2022.01.0~8.14~2022.01/bin:/Users/brandomiranda/opt/anaconda3/envs/meta_learning/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin
So my questions are:
- Why is this error happening when I open vscode if my terminal can find coq just fine?
- How do I fix this? What path do I need to set and why?
I was suggested to do:
eval $(opam env); dirname $(which coqtop)
but it didn't do anything or at least it didn't fix the problem...
I did copy pasted:
/Users/brandomiranda/.opam/__coq-platform.2022.01.0~8.14~2022.01/bin
to the prompt vscode gives me and it seems to have fixed it since my script was checked correctly. However, I find this disturbing cu I don't know what it did or why this worked.
Can someone explain to me why this worked -- especially since looking at my PATH (printed above) coq is globally available already?
fyi to install code use their plataform install scripts: https://github.com/coq/platform/blob/main/doc/README_macOS.md I suppose after doing that the above PATH would have been updated to the right thing that I copy pasted to the set global from vscode.
related:
发布评论
评论(1)
好吧,我想我修好了。这就是我所做的:
opam switch create Hammer_switch ocaml-base-compiler.4.12.0
并确保我有 xcode &家庭酿造/酿造。 (请注意,您似乎可以在 linux/ubuntu 中的 coda 中管理opam
)使用
$(opam env)
更新了我的路径(问:不是使用eval $(opam env)
?奇怪...)/Users/brandomiranda/.opam/__coq-platform.2022.01.0~8.15~beta1/bin
或echo $PATH
将 coq 部分复制到 vscode 的设置中。请注意,您的交换机中可能没有 coq 这个词,但它已经安装了,所以对我来说,我复制了/Users/brandomiranda/.opam/4.12.1/bin
并且这也有效。更多详细信息请参见下文。请参阅:https:// coq.discourse.group/t/how-to-have-vscode-find-coq/1582/2?u=brando90
对于 cotop vscode 请参阅(做
VSCode 设置(通常使用 Cmd 和逗号 ,)
前往此处):相关,但安装新插件时:https://github.com/lukaszcz/coqhammer/issues/122
vscode gitissue:https://github.com/coq-community/vscoq/issues/243
--
不使用官方平台脚本安装 Coq 的其他方式(使用 coq 设置 HPC 机器可能更容易?)
似乎你也可以这样安装 coq:
虽然我需要弄清楚
eval $(opam env)
去哪里。额外:关于放入 vscode 中的路径名的讨论
我的路径如下所示:
但我已经在交换机
4.12.1
上,并在其中安装了 coq,因为我运行了:在该状态下,我测试了 coq终端就在那里:
还有开关
__coq-platform.2022.01.0~8.14~2022.01 ocaml-base-compiler.4.10.2 __coq-platform.2022.01.0~8.14~2022.01
必须是在我进行平台安装时的不同时间设置的,但现在我忽略它并且我不在那个开关中,所以我不认为这很重要。Ok I fixed it I think. This is what I did:
opam switch create hammer_switch ocaml-base-compiler.4.12.0
and made sure I had xcode & hombrew/brew. (note you can haveopam
managed in coda in linux/ubuntu it seems)bash coq_platform_make.sh
updated my path with
$(opam env)
(Q: not witheval $(opam env)
? weird...)VSCode settings (usually with Cmd and comma ,)
) had the path from my PATH e.g./Users/brandomiranda/.opam/__coq-platform.2022.01.0~8.15~beta1/bin
or doecho $PATH
copy the coq part into vscode's setting. Note that your switch might not have the word coq in it but it istall has it installed so for me I copied/Users/brandomiranda/.opam/4.12.1/bin
and that worked too. More details in extra bellow.see: https://coq.discourse.group/t/how-to-have-vscode-find-coq/1582/2?u=brando90
for the cotop vscode see (do
VSCode settings (usually with Cmd and comma ,)
to go there):related but when installing new plugin: https://github.com/lukaszcz/coqhammer/issues/122
vscode gitissue: https://github.com/coq-community/vscoq/issues/243
--
Other way to install Coq not using the official plataform scripts (might be easier to set up HPC machines with coq?)
Seems you can install coq this way too:
though I need to figure out where
eval $(opam env)
goes.Extra: discussion on path names to put in vscode
My path looked as follows:
but I was already on the switch
4.12.1
already and installed coq in it because I ran:In that state I test coq in terminal and it was there:
and the switch
__coq-platform.2022.01.0~8.14~2022.01 ocaml-base-compiler.4.10.2 __coq-platform.2022.01.0~8.14~2022.01
must have been set up at a different time when I did plataform install but now I'm ignoring it and I'm not in that switch so I don't think it will matter much.