OCaml re-install on Windows

Hello,

My OCaml setup was broken, I decided to re-install it.

Went to windows application installation/removal and removed ‘DKML’ without any error message.

Then opened a powershell terminal and followed instructions in : Install OCaml

  1. The first step was ok (winget install Git.Git OCaml.opam)

And then :

PS H:\Ocaml> 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 powershell; 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] n
PS H:\Ocaml> (& opam env) -split '\r?\n' | ForEach-Object { Invoke-Expression $_ }
[ERROR] The selected switch playground is not installed. Please choose a different one using 'opam switch <name>', or use the '--switch <name>' flag.
PS H:\Ocaml> opam switch playground
[WARNING] Removing global switch 'playground' as it no longer exists
This version of opam requires an update to the layout of C:\Users\XXX\AppData\Local\opam from version 2.1 to
version 2.2, which can't be reverted.
You may want to back it up before going further.

Continue? [y/n] y
[NOTE] The 'jobs' option was reset, its value was 1 and its new value will vary according to the current number of
       cores on your machine. You can restore the fixed value using:
           opam option jobs=1 --global
Format upgrade done.
[ERROR] No switch playground is currently installed. Did you mean 'opam switch create playground'?
        Installed switches are:
          - H:\OCaml\stdlib-theme
          - H:\OCaml\GenArrayIter

I must confess I am not comfortable with opam switch, and I feel that having a ‘playground’ switch broken is not good. Any hint before I continue ?

I doubt using your old switches will work. If you are fine removing all of your switches, I would remove C:\Users\xxx\AppData\Local\opam instead, and then rerun your opam init command.

1 Like

Thank you. It worked !

Can you please remove my name from your post as I did in my initial post ?

1 Like