Installing OCaml on a Windows dev drive

Is there a way to install OCaml on a Windows dev drive?

I mean, by default OCaml installs itself on C:\Users, and from what I read, a dev drive needs to be configured as D:, E:, etc. I didn’t see a way to mount a subfolder on another drive.

You can set OPAMROOT as a system or user environment variable in the Control Panel. Then close your Command Prompt / Powershell, and then do opam init.

On my Windows PC I have a Y: dev drive and I point all the package managers to it:

Key Value
NUGET_PACKAGES Y:\user\beckf\packages\nuget
OPAMROOT Y:\user\beckf\packages\opam
CARGO_HOME Y:\packages\cargo
MAVEN_OPTS -Dmaven.repo.local=Y:\packages\maven
npm_config_cache Y:\packages\npm
PIP_CACHE_DIR Y:\packages\pip
VCPKG_DEFAULT_BINARY_CACHE Y:\packages\vcpkg

Most of that is documented at Set up a Dev Drive on Windows 11 | Microsoft Learn (OCaml is not on it, but they accept PRs).

2 Likes