vscode-ocaml-platform
vscode-ocaml-platform copied to clipboard
Unable to detect opam directory-local switch
I've just created a new, directory-local, opam switch on my machine for a project of mine:
$ git clone https://github.com/ELLIOTTCABLE/ocaml-ambient-context.git && cd ocaml-ambient-context
$ opam sw create ./ 4.14.1 --deps-only --with-test --with-doc --best-effort
(--best-effort
due to one of the packages in the directory, eio
, requiring OCaml 5.0; and this switch existing only to test 4.x
.)
Creating a workspace for that folder, and then opening it in VScode, I'm now unable to select that new opam switch:
I've also tried copy-pasting an explicit declaration from another of my workspaces into the .code-workspace
:
{
"folders": [
{
"path": "/Users/ec/Documents/Code/ocaml-ambient-context"
}
],
"settings": {
"ocaml.sandbox": {
"kind": "opam",
"root": "${workspaceFolder:ocaml-ambient-context}"
}
}
}
… which simply produces the error "Setting sandbox is invalid: Expected field 'switch'":
How can I debug this, and fix the extension's switch-detection?
Interestingly, if I try and use a 'custom sandbox' explicitly using opam exec
, it becomes clear that my VScode is having issues finding the opam
shim from my version-manager (asdf/rtx.)
$ opam exec --switch=/Users/ec/Documents/Code/ocaml-ambient-context -- ocamlc --version
/bin/sh: opam: command not found
$ opam exec --switch=/Users/ec/Documents/Code/ocaml-ambient-context -- ocamllsp --version
/bin/sh: opam: command not found
However, I don't think that's causing the above issue, because there's no erroneous output in either of the OCaml-related 'output' panes when I reset my config to the 'global' sandbox … and yet, despite the lack of errors, it's still unable to detect opam directory-local switches?
(How exactly does this go about finding directory-local switches? Just looking for the _opam
dir?)