# How to uninstall under Windows?

**URL:** https://discuss.ocaml.org/t/how-to-uninstall-under-windows/15593
**Category:** Learning
**Created:** [November 11, 2024, 4:58pm UTC](https://discuss.ocaml.org/t/how-to-uninstall-under-windows/15593 "2024-11-11T16:58:01Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![denismaier](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/denismaier/32/5420_2.png) [@denismaier](https://discuss.ocaml.org/u/denismaier)
#### Post date: [November 11, 2024, 4:58pm UTC](https://discuss.ocaml.org/t/how-to-uninstall-under-windows/15593/1 "2024-11-11T16:58:02Z")

</div>

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](https://github.com/diskuv/dkml-installer-ocaml/issues/105)), so that’s a different question.

I’ve now tried to install using the Winget method mentioned [here](https://ocaml.org/install#windows) and using the script based method mentioned [here](https://opam.ocaml.org/doc/Install.html). 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?

---

<div class="post-metadata">

### Author: ![kit-ty-kate](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/kit-ty-kate/32/5953_2.png) [@kit-ty-kate](https://discuss.ocaml.org/u/kit-ty-kate)
#### Post date: [November 11, 2024, 4:59pm UTC](https://discuss.ocaml.org/t/how-to-uninstall-under-windows/15593/2 "2024-11-11T16:59:59Z")

</div>

> [@denismaier](#):
>
> `opam init` doesn’t really seem to do much

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

---

<div class="post-metadata">

### Author: ![denismaier](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/denismaier/32/5420_2.png) [@denismaier](https://discuss.ocaml.org/u/denismaier)
#### Post date: [November 11, 2024, 5:59pm UTC](https://discuss.ocaml.org/t/how-to-uninstall-under-windows/15593/3 "2024-11-11T17:59:13Z")

</div>

> [@kit-ty-kate](#):
>
> would you be able to show the output of the command?

```auto
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.

```

---

<div class="post-metadata">

### Author: ![kit-ty-kate](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/kit-ty-kate/32/5953_2.png) [@kit-ty-kate](https://discuss.ocaml.org/u/kit-ty-kate)
#### Post date: [November 11, 2024, 6:28pm UTC](https://discuss.ocaml.org/t/how-to-uninstall-under-windows/15593/4 "2024-11-11T18:28:19Z")

</div>

The UI isn’t very helpful here, sorry about that (this is tracked in [ocaml/opam#5745](https://github.com/ocaml/opam/issues/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.

---

<div class="post-metadata">

### Author: ![denismaier](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/denismaier/32/5420_2.png) [@denismaier](https://discuss.ocaml.org/u/denismaier)
#### Post date: [November 11, 2024, 6:51pm UTC](https://discuss.ocaml.org/t/how-to-uninstall-under-windows/15593/5 "2024-11-11T18:51:17Z")

</div>

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

---

<div class="post-metadata">

### Author: ![denismaier](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/denismaier/32/5420_2.png) [@denismaier](https://discuss.ocaml.org/u/denismaier)
#### Post date: [November 11, 2024, 7:42pm UTC](https://discuss.ocaml.org/t/how-to-uninstall-under-windows/15593/6 "2024-11-11T19:42:28Z")

</div>

That was it. Thank you!
