如何告诉 vscode Coq 在哪里? (修复无法启动coqtop(coqtop))

发布于 2025-01-11 16:06:21 字数 2107 浏览 2 评论 0 原文

我试图在 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

所以我的问题是:

  1. 如果我的终端可以很好地找到 coq,为什么当我打开 vscode 时会发生此错误?
  2. 我该如何解决这个问题?我需要设置什么路径以及为什么?

有人建议我这样做:

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:
enter image description here

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:

  1. Why is this error happening when I open vscode if my terminal can find coq just fine?
  2. 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:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅唱ヾ落雨殇 2025-01-18 16:06:21

好吧,我想我修好了。这就是我所做的:

  1. 创建一个新开关,例如 opam switch create Hammer_switch ocaml-base-compiler.4.12.0 并确保我有 xcode &家庭酿造/酿造。 (请注意,您似乎可以在 linux/ubuntu 中的 coda 中管理 opam
  2. 我使用其二进制文件安装了 coq plataform https://github.com/coq/platform/blob/main/doc/README_macOS.md 并运行 bash coq_platform_make.sh
    使用 $(opam env) 更新了我的路径(问:不是使用 eval $(opam env)?奇怪...)
  3. 确保 vscode 设置中的 coqtop 路径(< code>VSCode 设置(通常使用 Cmd 和逗号,))具有我的 PATH 中的路径,例如/Users/brandomiranda/.opam/__coq-platform.2022.01.0~8.15~beta1/binecho $PATH 将 coq 部分复制到 vscode 的设置中。请注意,您的交换机中可能没有 coq 这个词,但它已经安装了,所以对我来说,我复制了 /Users/brandomiranda/.opam/4.12.1/bin 并且这也有效。更多详细信息请参见下文。
  4. 重新启动 vscode 几次以确保它正在运行上述路径。

请参阅: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:

# - install opam
# brew install opam # for mac
conda install -c conda-forge opam
opam init
# if doing local env? https://stackoverflow.com/questions/72522412/what-does-eval-opam-env-do-does-it-activate-a-opam-environment
# eval $(opam env)

# - install coq
# local install
#opam switch create . 4.12.1
#eval $(opam env)
#opam repo add coq-released https://coq.inria.fr/opam/released
#opam install coq

# If you want a single global (wrt conda) coq installation (for say your laptop):
opam switch create 4.12.1
opam switch 4.12.1
# eval $(opam env)  # why don't I need this in the global, what makes this global?
opam repo add coq-released https://coq.inria.fr/opam/released
opam install coq

虽然我需要弄清楚 eval $(opam env) 去哪里。


额外:关于放入 vscode 中的路径名的讨论

我的路径如下所示:

(iit_synthesis) brandomiranda~ ❯ echo $PATH
/Users/brandomiranda/.opam/4.12.1/bin:/Users/brandomiranda/miniconda/envs/iit_synthesis/bin:/Users/brandomiranda/miniconda/condabin:/usr/local/bin:/Users/brandomiranda/.opam/4.12.1/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin

但我已经在交换机 4.12.1 上,并在其中安装了 coq,因为我运行了:

# - install opam
brew install opam
# https://stackoverflow.com/questions/72522266/how-does-one-install-opam-with-conda-for-mac-apple-os-x
# conda install -c conda-forge opam
opam init
# if doing local env? https://stackoverflow.com/questions/72522412/what-does-eval-opam-env-do-does-it-activate-a-opam-environment
#eval $(opam env)

# - install coq
# local install
#opam switch create . 4.12.1
#eval $(opam env)
#opam repo add coq-released https://coq.inria.fr/opam/released
#opam install coq

# If you want a single global (wrt conda) coq installation (for say your laptop):
opam switch create 4.12.1
opam switch 4.12.1
eval $(opam env)
opam repo add coq-released https://coq.inria.fr/opam/released
opam install coq

在该状态下,我测试了 coq终端就在那里:

(iit_synthesis) brandomiranda~ ❯ opam switch
#  switch                                 compiler                    description
→  4.12.1                                 ocaml-base-compiler.4.12.1  4.12.1
   __coq-platform.2022.01.0~8.14~2022.01  ocaml-base-compiler.4.10.2  __coq-platform.2022.01.0~8.14~2022.01
(iit_synthesis) brandomiranda~ ❯ coqtop
Welcome to Coq 8.15.1

Coq < ^C
Error: User interrupt.

Coq < ^D

还有开关 __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:

  1. create a new switch e.g. opam switch create hammer_switch ocaml-base-compiler.4.12.0 and made sure I had xcode & hombrew/brew. (note you can have opam managed in coda in linux/ubuntu it seems)
  2. I installed the coq plataform using their binaries https://github.com/coq/platform/blob/main/doc/README_macOS.md and ran bash coq_platform_make.sh
    updated my path with $(opam env) (Q: not with eval $(opam env)? weird...)
  3. made sure coqtop path in the vscode settings (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 do echo $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.
  4. restarted vscode several times to make sure it was running the above path.

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):

enter image description here


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:

# - install opam
# brew install opam # for mac
conda install -c conda-forge opam
opam init
# if doing local env? https://stackoverflow.com/questions/72522412/what-does-eval-opam-env-do-does-it-activate-a-opam-environment
# eval $(opam env)

# - install coq
# local install
#opam switch create . 4.12.1
#eval $(opam env)
#opam repo add coq-released https://coq.inria.fr/opam/released
#opam install coq

# If you want a single global (wrt conda) coq installation (for say your laptop):
opam switch create 4.12.1
opam switch 4.12.1
# eval $(opam env)  # why don't I need this in the global, what makes this global?
opam repo add coq-released https://coq.inria.fr/opam/released
opam install coq

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:

(iit_synthesis) brandomiranda~ ❯ echo $PATH
/Users/brandomiranda/.opam/4.12.1/bin:/Users/brandomiranda/miniconda/envs/iit_synthesis/bin:/Users/brandomiranda/miniconda/condabin:/usr/local/bin:/Users/brandomiranda/.opam/4.12.1/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin

but I was already on the switch 4.12.1 already and installed coq in it because I ran:

# - install opam
brew install opam
# https://stackoverflow.com/questions/72522266/how-does-one-install-opam-with-conda-for-mac-apple-os-x
# conda install -c conda-forge opam
opam init
# if doing local env? https://stackoverflow.com/questions/72522412/what-does-eval-opam-env-do-does-it-activate-a-opam-environment
#eval $(opam env)

# - install coq
# local install
#opam switch create . 4.12.1
#eval $(opam env)
#opam repo add coq-released https://coq.inria.fr/opam/released
#opam install coq

# If you want a single global (wrt conda) coq installation (for say your laptop):
opam switch create 4.12.1
opam switch 4.12.1
eval $(opam env)
opam repo add coq-released https://coq.inria.fr/opam/released
opam install coq

In that state I test coq in terminal and it was there:

(iit_synthesis) brandomiranda~ ❯ opam switch
#  switch                                 compiler                    description
→  4.12.1                                 ocaml-base-compiler.4.12.1  4.12.1
   __coq-platform.2022.01.0~8.14~2022.01  ocaml-base-compiler.4.10.2  __coq-platform.2022.01.0~8.14~2022.01
(iit_synthesis) brandomiranda~ ❯ coqtop
Welcome to Coq 8.15.1

Coq < ^C
Error: User interrupt.

Coq < ^D

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文