reasonml-editor / vscode-reasonml

OCaml & Reason support for Visual Studio Code
Apache License 2.0
491 stars 62 forks source link

WSL: opam local switch environment #287

Open vogler opened 4 years ago

vogler commented 4 years ago

If I run code . from a WSL shell, the current environment variables are not inherited in vscode (see here). If merlin is only installed in the local switch and not in the global switch, it won't be found since PATH won't include the local _opam/bin/. Same for other local binaries. I could set paths in the workspace settings (.vscode/settings.json) like this:

{
  "reason.path.ocamlmerlin": "_opam/bin/ocamlmerlin",
  "reason.path.ocamlfind": "_opam/bin/ocamlfind",
  "reason.path.ocpindent": "_opam/bin/ocp-indent",
  "reason.path.opam": "_opam/bin/opam"
}

However if I have code in a workspace foo/bar/ and open vscode in the parent workspace foo/ it would fail unless I adjust the settings there as well (set paths to "bar/_opam/bin/ocamlmerlin" etc.).

If ocamlmerlin is not found, it could run opam env for the current directory to get the fixed PATH that includes the local switch. Alternatively: