How to uninstall under Windows?

Hi,
somehow I don’t manage to install OCaml under Windows. (No problems whatsoever under Linux…) I have had an older DKML installation that I probably need to uninstall first (I’ve already opened an issue asking about that here: How to uninstall? · Issue #105 · diskuv/dkml-installer-ocaml · GitHub), so that’s a different question.

I’ve now tried to install using the Winget method mentioned here and using the script based method mentioned here. However, nothing of that really works: powershell says ocaml is not found; opam init doesn’t really seem to do much; there seems to be no pacman in the opam managed cygwin installation; with my local msys installation I’ve managed to make some progress, but it also breaks somewhere in the middle…

So, I guess I should probably just delete everything and start again from a clean slate. How can I remove everything opam/ocaml related? Is there an automatic way, or do you just delete every ocaml/opam related directory, and remove those from the path? If so, which directories would that be?

would you be able to show the output of the command?

PS C:\Users\denis> opam init

<><> Required setup - please read <><><><><><><><><><><><><><><><><><><><><>  🐫

  In normal operation, opam only alters files within ~\AppData\Local\opam.

  However, to best integrate with your system, some environment variables
  should be set. When you want to access your opam installation, you will
  need to run:

    (& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }

  You can always re-run this setup with 'opam init' later.

opam doesn't have any configuration options for pwsh; you will have to run (& opam env) -split '\r?\n' | ForEach-Object {
Invoke-Expression $_ } whenever you change you current 'opam switch' or start a new terminal session. Alternatively, would you like
to select a different shell? [y/n]
PS C:\Users\denis> (& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }
PS C:\Users\denis> ocaml
ocaml: The term 'ocaml' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

The UI isn’t very helpful here, sorry about that (this is tracked in ocaml/opam#5745).
What happens here is that opam is already initialized from your previous installation and the current switch is either empty or broken.

You can fix this by removing your C:\Users\<user>\AppData\Local\opam directory, then calling opam init again which should work and should create a new default switch with the latest ocaml compiler.

1 Like

Ok. I’ll try. But just for the record, I’ve already tried with --reinit, but that failed as well.

That was it. Thank you!

1 Like