Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to detect opam directory-local switch #1267

Open
ELLIOTTCABLE opened this issue Oct 31, 2023 · 1 comment
Open

Unable to detect opam directory-local switch #1267

ELLIOTTCABLE opened this issue Oct 31, 2023 · 1 comment

Comments

@ELLIOTTCABLE
Copy link

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
Copy link
Author

ELLIOTTCABLE commented Oct 31, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant