vscode-ocaml-platform icon indicating copy to clipboard operation
vscode-ocaml-platform copied to clipboard

Unable to detect opam directory-local switch

Open ELLIOTTCABLE opened this issue 1 year ago • 1 comments

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:

image

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'":

Screenshot 2023-10-31 at 1 23 56 PM

How can I debug this, and fix the extension's switch-detection?

ELLIOTTCABLE avatar Oct 31 '23 18:10 ELLIOTTCABLE

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

ELLIOTTCABLE avatar Oct 31 '23 18:10 ELLIOTTCABLE