# How to locate all the switches in Visual Studio Code

**URL:** <https://discuss.ocaml.org/t/how-to-locate-all-the-switches-in-visual-studio-code/15147>\
**Category:** Learning\
**Tags:** opam-switch\
**Created:** [August 15, 2024, 11:38pm UTC](https://discuss.ocaml.org/t/how-to-locate-all-the-switches-in-visual-studio-code/15147 "2024-08-15T23:38:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)\
**Post date:** [August 15, 2024, 11:38pm UTC](https://discuss.ocaml.org/t/how-to-locate-all-the-switches-in-visual-studio-code/15147/1 "2024-08-15T23:38:47Z")

</div>

I installed WLS2, and then Ubuntu on Windows 11, and finally OCaml. Here are the switches that I have:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/ocaml/original/2X/9/94dbd5549af8b3030d997e6fccae9465c0bc53d4.png)  
However, Visual Studio Code is unable to locate those:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/ocaml/original/2X/4/4dcaa8ed1f1cc561ae94121f86426fcf5d35bec6.png)

Would you kindly help me in locating the folder with those switches on my machine?

---

<div class="post-metadata">

**Author:** ![jbeckford](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jbeckford/32/3027_2.png) [@jbeckford](https://discuss.ocaml.org/u/jbeckford)\
**Post date:** [August 16, 2024, 4:27am UTC](https://discuss.ocaml.org/t/how-to-locate-all-the-switches-in-visual-studio-code/15147/2 "2024-08-16T04:27:58Z")

</div>

WSL2 can be a bit tricky since executables can run in native Windows or inside WSL2 … and it gives you no indication which one.

So first, can you check that a WSL2 opam is running? Just dump the output from the following:

```sh
command -v opam
opam var --global
echo $PATH

```

Assuming that `opam` really is a WSL2 opam, then you also need to make sure VS Code is switched to WSL2.

So second, at the bottom left of your VS Code is a button that should be blue if VS Code is switched to WSL2. If it isn’t blue click on that and make sure it is WSL2.

Last, use `Select Sandbox` not `Open Folder` for your switches. You only use the `Open Folder` if the `opam switch` shows an absolute path.

---

<div class="post-metadata">

**Author:** ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)\
**Post date:** [August 16, 2024, 5:05pm UTC](https://discuss.ocaml.org/t/how-to-locate-all-the-switches-in-visual-studio-code/15147/3 "2024-08-16T17:05:33Z")

</div>

I believe that I am half way there. So, let me start with the outputs of the commands:

```auto
pyvovale@DESKTOP-64CEB9F:~$ command -v opam
/usr/bin/opam
pyvovale@DESKTOP-64CEB9F:~$ opam var --global
arch x86_64 # Inferred from system
exe # Suffix needed for executable filenames (Windows)
jobs 7 # The number of parallel jobs set up in opam configuration
make make # The 'make' command to use
opam-version 2.2.0 # The currently running opam version
os linux # Inferred from system
os-distribution ubuntu # Inferred from system
os-family debian # Inferred from system
os-version 22.04 # Inferred from system
root /home/pyvovale/.opam # The current opam root directory
switch ocaml_52 # The identifier of the current switch
sys-ocaml-arch x86_64 # Target architecture of the OCaml compiler present on your system
sys-ocaml-cc cc # Host C Compiler type of the OCaml compiler present on your system
sys-ocaml-libc libc # Host C Runtime Library type of the OCaml compiler present on your system
sys-ocaml-system linux # Target system of the OCaml compiler present on your system
sys-ocaml-version 4.13.1 # OCaml version present on your system independently of opam, if any
pyvovale@DESKTOP-64CEB9F:~$ echo $PATH
/home/pyvovale/.opam/ocaml_52/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/Common Files/Oracle/Java/javapath:/mnt/c/Program Files/Microsoft/jdk-11.0.23.9-hotspot/bin:/mnt/c/windows/system32:/mnt/c/windows:/mnt/c/windows/System32/Wbem:/mnt/c/windows/System32/WindowsPowerShell/v1.0/:/mnt/c/windows/System32/OpenSSH/:/mnt/c/Program Files/Microsoft SQL Server/150/Tools/Binn/:/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/170/Tools/Binn/:/mnt/c/Program Files/dotnet/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/HP/HP One Agent:/mnt/c/Program Files (x86)/sbt/bin:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/PowerShell/7/:/mnt/c/Users/shuri/AppData/Local/Programs/opam/bin:/mnt/c/Users/shuri/.elan/bin:/mnt/c/Users/shuri/.cargo/bin:/mnt/c/Users/shuri/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/shuri/AppData/Local/Programs/MiKTeX/miktex/bin/x64/:/mnt/c/Users/shuri/.dotnet/tools:/mnt/c/Users/shuri/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/ghcup/bin:/mnt/c/Users/shuri/AppData/Local/Coursier/data/bin:/mnt/c/Users/shuri/.dotnet/tools:/mnt/c/Users/shuri/.dotnet/tools:/mnt/c/MinGW/bin:/mnt/c/Users/shuri/.dotnet/tools:/snap/bin

```

In Visual Studio Code, I clicked to the bottom left corner on ‘Connect to WSL’, then I installed OCaml Platform on Ubuntu, and then all the switches became visible. However, I could not figure out how may I navigate to the folder on my C drive where some of the .ml files are located. Moreover, when I click on some of the recently opened folders I am getting immediately disconnected from from the WSL server. Would you kindly provide me with some further assistance?

---

<div class="post-metadata">

**Author:** ![jbeckford](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jbeckford/32/3027_2.png) [@jbeckford](https://discuss.ocaml.org/u/jbeckford)\
**Post date:** [August 16, 2024, 5:56pm UTC](https://discuss.ocaml.org/t/how-to-locate-all-the-switches-in-visual-studio-code/15147/4 "2024-08-16T17:56:45Z")

</div>

Just like on Windows where you can mount a network path to a drive letter (ex. `Z:`), in WSL2 it mounts Windows drives to a Unix path.

On your machine the `C:` drive was mapped to `/mnt/c` in WSL2.  
So `C:\dev\OCaml\RealWorldOCaml` is at `/mnt/c/dev/OCaml/RealWorldOCaml`.

But a word of caution: These mounts can be 100X slower than a normal disk drive. When people complain about the speed of WSL2, the mount is almost always the culprit. Microsoft explains the details at [Working across file systems | Microsoft Learn](https://learn.microsoft.com/en-us/windows/wsl/filesystems#file-storage-and-performance-across-file-systems). TLDR: Move your files to `/home/pyvovale/dev/OCaml/RealWorldOCaml` (which is on a Linux ext4 filesystem) and then open that folder in VS Code.

(For future people who are just starting WSL2, you’ll need to learn how to move/copy/explore/change directories from the Linux command line. Try [Linux Commands in more detail | High Performance Computing](https://www.hpc.iastate.edu/guides/introduction-to-hpc-clusters/linux-commands-in-more-detail)).

---

<div class="post-metadata">

**Author:** ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)\
**Post date:** [August 16, 2024, 8:11pm UTC](https://discuss.ocaml.org/t/how-to-locate-all-the-switches-in-visual-studio-code/15147/5 "2024-08-16T20:11:57Z")

</div>

Thank you so much! Moved everything to home directory

Actually Visual Studio Code gives a warning when trying to access a path with mnt

Would you mind answering a linux question which not related to OCaml? Here it is:  
[This section](https://learn.microsoft.com/en-us/windows/wsl/filesystems#view-your-current-directory-in-windows-file-explorer) intrigued me quite a bit. I am getting an error that wsl.localhost is not accessible when trying to view linux folder with the explorer. A solution is presented [here](https://askubuntu.com/questions/1483564/wsl-localhost-is-not-accessible-open-folder-error), but I did not understand it. Do you have some time to explain it to me

---

<div class="post-metadata">

**Author:** ![jbeckford](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/jbeckford/32/3027_2.png) [@jbeckford](https://discuss.ocaml.org/u/jbeckford)\
**Post date:** [August 16, 2024, 8:24pm UTC](https://discuss.ocaml.org/t/how-to-locate-all-the-switches-in-visual-studio-code/15147/6 "2024-08-16T20:24:12Z")

</div>

I can access `\\wsl$` from the File Explorer, although `\\wsl.localhost$` does not work.

Other than that, I don’t have a clue.

---

<div class="post-metadata">

**Author:** ![pyvovale](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/pyvovale/32/5489_2.png) [@pyvovale](https://discuss.ocaml.org/u/pyvovale)\
**Post date:** [August 16, 2024, 9:15pm UTC](https://discuss.ocaml.org/t/how-to-locate-all-the-switches-in-visual-studio-code/15147/7 "2024-08-16T21:15:27Z")

</div>

[Here is a solution](https://www.avonture.be/blog/wsl-windows-explorer/), to the issue with \wsl$
