ocamllabs / vscode-ocaml-platform

Visual Studio Code extension for OCaml
ISC License
342 stars 75 forks source link

Supporting Windows (Diskuv OCaml) distribution #977

Closed jonahbeckford closed 1 year ago

jonahbeckford commented 2 years ago

On Windows the plugin defaults to requiring ocaml.useOcamlEnv.

The Diskuv OCaml (DKML) distribution for Windows does not need wrappers. It works with the OCaml VSCode plugin as-is, and the plug-in doesn't see any switches when ocaml.useOCamlEnv is on.

But I'm needing to tell new users to disable the ocamlenv setting. What do you suggest we do for Windows users?


Nitty gritty details if it helps:

(
  ("DiskuvOCamlVarsVersion" ("2"))
  ("DiskuvOCamlHome" ("C:\\Users\\beckf\\AppData\\Local\\Programs\\DISKUV~1\\0"))
  ("DiskuvOCamlBinaryPaths" ("C:\\Users\\beckf\\AppData\\Local\\Programs\\DISKUV~1\\0\\usr\\bin" "C:\\Users\\beckf\\AppData\\Local\\Programs\\DISKUV~1\\0\\bin"))
  ("DiskuvOCamlMSYS2Dir" ("C:\\Users\\beckf\\AppData\\Local\\Programs\\DISKUV~1\\tools\\MSYS2"))
  ("DiskuvOCamlDeploymentId" ("v-0.4.0-prerel91;ocaml-4.12.1;opam-2.2.0~alpha~dev;inotify-36d18f3dfe042b21d7136a1479f08f0d8e30e2f9;msys2-999CED2C8F5FF6A2;docker-B01818D2C9F9286A;pkgs-E9B3EA78336D2491;bins-E81FF8D69425188D;stubs-4E6958B274EAB043;toplevels-80941AA1C64DA259"))
  ("DiskuvOCamlVersion" ("0.4.0-prerel91"))
)
mnxn commented 2 years ago

I think the most elegant solution would be to check if ocaml-env exists before using it. A PATH check could done inside this branch: https://github.com/ocamllabs/vscode-ocaml-platform/blob/5d33e8a8e2b1475296d0c971a19885987ce09d11/src/ocaml_windows.ml#L10-L11

Since Diskuv OCaml doesn't have ocaml-env, the extension will use the Windows executables unless OCaml for Windows is installed. If a user has both OCaml for Windows and Diskuv OCaml, the ocaml.useOcamlEnv setting can be used to decided which is used:

jonahbeckford commented 2 years ago

That is perfect! Thanks for the quick turnaround. I'll see about testing the PR.