Dkml unable to find Windows Build Tools

I installed ocaml using the winget install Diskuv.Ocaml command after countless tries with the offical installer not working. ocamlc and ocamlopt with utop all work but dune is not installed and when i try to run dkml or opam commands it throws the message below:
`dkml: [WARNING] Detected that a Visual Studio compatible with DkML has not been located. Locating it now. ETA: 1 minute.Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send. At C:\Users\yusuf\AppData\Local\Temp\dkml-initsystem-de-902afe\scripts\vendor\drd\src\windows\Machine\Machine.psm1:238 char:9 + Invoke-WebRequest -Uri https://github.com/microsoft/vssetup.p … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc eption + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand Expand-Archive : The path ‘C:\Users\yusuf\AppData\Local\Temp\vssetup\VSSetup.zip’ either does not exist or is not a valid file system path. At C:\Users\yusuf\AppData\Local\Temp\dkml-initsystem-de-902afe\scripts\vendor\drd\src\windows\Machine\Machine.psm1:240 char:9 + Expand-Archive $TempPath\VSSetup.zip $VsSetupModules + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (C:\Users\yusuf.…tup\VSSetup.zip:String) [Expand-Archive], InvalidOpe rationException + FullyQualifiedErrorId : ArchiveCmdletPathNotFound,Expand-Archive Import-Module : The specified module ‘VSSetup’ was not loaded because no valid module file was found in any module directory. At C:\Users\yusuf\AppData\Local\Temp\dkml-initsystem-de-902afe\scripts\vendor\drd\src\windows\Machine\Machine.psm1:243 char:5 + Import-Module VSSetup + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceUnavailable: (VSSetup:String) [Import-Module], FileNotFoundException + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand Get-VSSetupInstance : The term ‘Get-VSSetupInstance’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Users\yusuf\AppData\Local\Temp\dkml-initsystem-de-902afe\scripts\vendor\drd\src\windows\Machine\Machine.psm1:392 char:21 + $allinstances = Get-VSSetupInstance + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-VSSetupInstance:String) , CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Select-VSSetupInstance : The term ‘Select-VSSetupInstance’ is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\Users\yusuf\AppData\Local\Temp\dkml-initsystem-de-902afe\scripts\vendor\drd\src\windows\Machine\Machine.psm1:394
char:34

  • $instances = $allinstances | Select-VSSetupInstance `
    
  •                              ~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (Select-VSSetupInstance:String) , CommandNotFoundException
    • FullyQualifiedErrorId : CommandNotFoundException

WARNING:

BEGIN Dump all incompatible Visual Studio(s)

WARNING: END Dump all incompatible Visual Studio(s) WARNING: There is no Visual Studio 2015 Update 3 or later with the following: a) MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.26 or v14.25 or v14.29) b) MSVC v142 - VS 2019 C++ x64/x86 build tools (Latest) c) Windows 10 SDK (10.0.18362 or 10.0.19041)

CHOOSE ONE OF THE SOLUTIONS BELOW

SOLUTION 1 (Recommended)

  1. Install winget (skip this step on Windows 11 or later since already installed):
    Use the winget tool to install and manage applications | Microsoft Learn)
  2. Run:
    winget install Microsoft.VisualStudio.2019.BuildTools --override “–wait --passive --installPath C:\VS
    –addProductLang En-us --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended”

    dkml: FATAL: \cache-vsstudio.bat exited with error code 1`
    I have followed the solutions, restarted my PC, uninstalled and reinstalled many times but nothing has changed.

Those are the first errors. Try running “dkml” again in case there was a temporary outage at GitHub or something wrong with the connectivity between your PC and the Internet. Failing that, you are looking at something interfering on your PC: a proxy, malware checker, VPN, firewall, etc.

I got it to work. So i think it’s trying to make a web request to https://github.com/microsoft/vssetup.p which doesn’t exist but i tracked down the vssetup github page to https://github.com/microsoft/vssetup.powershell. I then ran the following command i saw on the repo Install-Module VSSetup -Scope CurrentUser in a powershell prompt, it asked to install nuget which i allowed and another package (cannot recall) which i also allowed. After that i restarted the powershell prompt, then reran dkml init this time it tried to run the webrequest but when that didn’t work, it somehow was still able to find the right build tools (reading from the github repo the package I installed helps to “… query instances of Visual Studio 2017 and newer”) and do all the necessary configuration. I can say dkml and opam commands now work.