Can you confirm you cannot create, for example, â5.1.0â ?
Could you share with us how do you set up your opam
?
I have a similar error some days ago, and it was related to the missing of the env var OPAMCURL
and OPAMFETCH
, check if exists into your environment, if not, set them, e.g.: export OPAMCURL=curl
Other way, check the repository that have been inserted into opam init
, validate if this version exists on that repository.
For future reference, please post code extracts in plain text form, not as screenshots, unless impossible. Text is more accessible. Thanks!
Yes, I canât create it:
[ERROR] No compiler matching '5.1.0+msvc64' found, use 'opam switch list-available' to see what is available, or use '--packages' to select packages explicitly.
Hey,
I followed this tutorial: OCaml for Windows - Installation
The graphical installer didnât work for me so I tried following the manual install guide. I completed all the steps. But I had the same error there too so I tried to create a switch from Windows CMD.
The variables you mentioned werenât defined for me as well, I defined them by set OPAMCURL=curl
and set OPAMFETCH=wget
. I checked if they were truly set by:
echo %OPAMCURL%
curl
and
echo %OPAMFETCH%
wget
Then I updated opam:
opam update
<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] no changes from git+https://github.com/fdopen/opam-repository-mingw.git#opam2
The same error occured again:
opam switch create 4.14.0+mingw64c
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ocaml-variants.4.14.0+mingw64c] found in cache
[ERROR] The sources of the following couldnât be obtained, aborting:
- ocaml-variants.4.14.0+mingw64c
Switch initialisation failed: clean up? (ânâ will leave the switch partially installed) [Y/n] y
Fatal error: exception Not_found
Iâm afraid youâve hit the deprecated OCaml for Windows (see the deprecation announcement from 2021 on the site.
That repository has been partially maintained elsewhere (see Sunsetting opam-repository-mingw), but thereâs no support for OCaml 5.x in it.
However, we released opam 2.2.0 this week! Iâd suggest reversing the manual installation you did and heading over to [ANN] opam 2.2.0 is out! for the installation details
Hello,
I have followed the guide you have linked and successfully upgraded opam.
Now I have a different error, which I think is progress!
C:\Users\omerk>opam switch create ocaml-variants 4.14.0+msvc64
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: [âocaml-variantsâ {= â4.14.0+msvc64â}]
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
ⶠinstalled base-bigarray.base
ⶠinstalled base-threads.base
ⶠinstalled base-unix.base
[ERROR] Failed to get extra source âinline-flexdll.patchâ of ocaml-variants.4.14.0+msvc64: Download command failed
#=== ERROR while fetching sources for ocaml-variants.4.14.0+msvc64 ============#
OpamSolution.Fetch_fail(âhttps://gist.githubusercontent.com/fdopen/afe3140904cc975cc9d2e4992e13d547/raw/3d8b647eb196a3174e6c6105881e5d6a4b8fa166/inline-flexdll.patch (Download command failed: "c:\\sox-14-4-2\\wget.exe --content-disposition -t 3 -O C:\\Users\\omerk\\AppData\\Local\\Temp\\opam-9460-b7cd42\\inline-flexdll.patch.part -U opam/2.2.0 â https://gist.githubusercontent.com/fdopen/afe3140904cc975cc9d2e4992e13d547/raw/3d8b647eb196a3174e6c6105881e5d6a4b8fa166/inline-flexdll.patch\â exited with code 1)")
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
ââ The following actions failed
â ⌠fetch ocaml-variants 4.14.0+msvc64
ââ
ââ The following changes have been performed (the rest was aborted)
â ⶠinstall base-bigarray base
â ⶠinstall base-threads base
â ⶠinstall base-unix base
ââ
# Run for /f âtokens=*â %i in (âopam env --switch=ocaml-variantsâ) do @%i to update the current shell environment
Switch initialisation failed: clean up? (ânâ will leave the switch partially installed) [y/n] y
Progress, indeed! Iâd suggest reinitialising opam completely, which Iâd do by running
opam var root
and noting the directory it replies with (I expect, as it was OCaml for Windows this will be something ending with \.opam
). I would delete (or rename, if you want to be more cautious) that directory and then re-run opam init
.
Out of curiosity (because it may be related to the download problem), which version of Windows are you on?
Hey, I deleted the .\opam
direcory, then re-ran opam init
:
PS C:\Users\omerk> 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
then the program terminated.
Then I checked to see if .\opam
was created and it wasnât there.
PS C:\Users\omerk> opam var root
now returns
[ERROR] No config file found for switch playground. Switch broken?
C:\Users\omerk\AppData\Local\opam
I ran opam switch list-available
and this time the list was different, it included versions until 5.3.0+trunk
.
This time I got the same error:
PS C:\Users\omerk> opam switch create ocaml-variants 5.3.0+trunk
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: [âocaml-variantsâ {= â5.3.0+trunkâ}]
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
â installed base-bigarray.base
â installed base-threads.base
â installed base-unix.base
[ERROR] Failed to get sources of ocaml-variants.5.3.0+trunk: Download command failed
#=== ERROR while fetching sources for ocaml-variants.5.3.0+trunk ==============#
OpamSolution.Fetch_fail(âhttps://github.com/ocaml/ocaml/archive/trunk.tar.gz (Download command failed: "c:\\sox-14-4-2\\wget.exe --content-disposition -t 3 -O C:\\Users\\omerk\\AppData\\Local\\opam\\ocaml-variants\\.opam-switch\\sources\\ocaml-variants.5.3.0+trunk\\trunk.tar.gz.part -U opam/2.2.0 â https://github.com/ocaml/ocaml/archive/trunk.tar.gz\â exited with code 1)")
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
± The following actions failed
| - fetch ocaml-variants 5.3.0+trunk
±
± The following changes have been performed (the rest was aborted)
| - install base-bigarray base
| - install base-threads base
| - install base-unix base
±
# Run (& opam env --switch=ocaml-variants) -split â\r?\nâ | ForEach-Object { Invoke-Expression $_ } to update the
current shell environment
Switch initialisation failed: clean up? (ânâ will leave the switch partially installed) [y/n] y
PS: I am running these on Windows 10
Ah - hereâs the problem. Iâm afraid that 9 year old version of wget doesnât support the correct TLS stack, having run it locally:
C:\Devel\sox-14-4-2>wget.exe --content-disposition -t 3 -O trunk.tar.gz.part -U opam/2.2.0 https://github.com/ocaml/ocaml/archive/trunk.tar.gz
--2024-07-07 10:35:51-- https://github.com/ocaml/ocaml/archive/trunk.tar.gz
Resolving github.com... 20.26.156.215
Connecting to github.com|20.26.156.215|:443... connected.
OpenSSL: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
Unable to establish SSL connection.
I would possibly simply delete c:\sox-14-4-2\wget.exe
(or, again, rename), as I imagine that wget isnât able to do anything useful these days! (tracking the issue of opamâs UI in this failure mode in Test the download command more explicitly · Issue #6072 · ocaml/opam · GitHub, though).
Itâs correct that the .opam directory wasnât created - opam 2.2.0 by default creates the root in a the rather more Windows-like %LOCALAPPDATA%\opam (which it noted at the top of the opam init
)
I deleted c:\sox-14-4-2\wget.exe
. Then ran again and got this:
C:\Users\omerk>opam switch create 5.3.0+trunk
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: [âocaml-variantsâ {= â5.3.0+trunkâ}]
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
ⶠinstalled base-bigarray.base
ⶠinstalled base-threads.base
ⶠinstalled base-unix.base
⌠retrieved ocaml-variants.5.3.0+trunk (https://github.com/ocaml/ocaml/archive/trunk.tar.gz)
[ERROR] The compilation of ocaml-variants.5.3.0+trunk failed at âmake -j11â.
#=== ERROR while compiling ocaml-variants.5.3.0+trunk =========================#
# context 2.2.0 | win32/x86_64 | | https://opam.ocaml.org#2b6e600e
# path ~\AppData\Local\opam\5.3.0+trunk.opam-switch\build\ocaml-variants.5.3.0+trunk
# command C:\msys64\usr\bin\make.exe -j11
# exit-code 2
# env-file ~\AppData\Local\opam\log\ocaml-variants-16640-36f7fd.env
# output-file ~\AppData\Local\opam\log\ocaml-variants-16640-36f7fd.out
### output ###
# GEN runtime/primitives
# GEN runtime/caml/opnames.h
# GEN runtime/caml/jumptbl.h
# CC runtime/sak.o
# MKEXE runtime/sak
# GEN runtime/prims.c
# C:/msys64/ucrt64/bin/âŠ/lib/gcc/x86_64-w64-mingw32/13.2.0/âŠ/âŠ/âŠ/âŠ/x86_64-w64-mingw32/bin/ld.exe: C:/msys64/ucrt64/bin/âŠ/lib/gcc/x86_64-w64-mingw32/13.2.0/âŠ/âŠ/âŠ/âŠ/lib/libmingw32.a(lib64_libmingw32_a-crtexewin.o): in functionmain': \# C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtexewin.c:67:(.text.startup+0xbd): undefined reference to
WinMainâ
# collect2.exe: error: ld returned 1 exit status
# make: *** [Makefile:1326: runtime/sak] Error 1
# make: *** Waiting for unfinished jobsâŠ
<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
ââ The following actions failed
â λ build ocaml-variants 5.3.0+trunk
ââ
ââ The following changes have been performed (the rest was aborted)
â ⶠinstall base-bigarray base
â ⶠinstall base-threads base
â ⶠinstall base-unix base
ââ
# Run for /f âtokens=*â %i in (âopam env --switch=5.3.0+trunkâ) do @%i to update the current shell environment
Switch initialisation failed: clean up? (ânâ will leave the switch partially installed) [y/n] y
Also, I donât know if it helps in any way, when I switch to bash everything works fine. Which doesnât help me (I guess) because I want to use VS Code as my IDE.
Hmm, thereâs still something unexpected about your setup: whatâs your PATH? In particular, itâs unexpected that youâre picking up a ucrt64 installation of MSYS2 (OCaml doesnât support that). Could you also post the output of opam config report
and opam config list
?
When youâre switching to bash, exactly how are you doing that (i.e. what command do you run or shortcut do you use)?
Sorry, i am a beginner. How do I paste my PATH
here? Do you mean the all environment variables in my PATH? if so I canât copy paste all that here, but I have attached a screenshot:
C:\Users\omerk>opam config report
# opam config report
# opam-version 2.2.0
# self-upgrade no
# system arch=x86_64 os=win32 os-distribution=msys2 os-version=10.0.19041
# solver builtin-mccs+glpk
# install-criteria -removed,-count[avoid-version,changed],-count[version-lag,request],-count[version-lag,changed],-count[missing-depexts,changed],-changed
# upgrade-criteria -removed,-count[avoid-version,changed],-count[version-lag,solution],-count[missing-depexts,changed],-new
# jobs 11
[ERROR] No config file found for switch playground. Switch broken?
# repositories 1 (http), 1 (version-controlled) (default repo at 2b6e600e)
# pinned 0
# current-switch playground
# invariant [ ]
# compiler-packages none
C:\Users\omerk>opam config list
<><> Global opam variables ><><><><><><><><><><><><><><><><><><><><><><><><><><>
arch x86_64 #
Inferred from system
exe .exe #
Suffix needed for executable filenames (Windows)
jobs 11 #
The number of parallel jobs set up in opam configuration
make make #
The 'make' command to use
mingw-chost x86_64-w64-mingw32 #
Set through 'opam var'
mingw-package-prefix mingw-w64-clang-x86_64 #
Set through 'opam var'
mingw-prefix /clang64 #
Set through 'opam var'
msys2-nativedir C:\Users\omerk\AppData\Local\Programs\DkMLNative\tools\MSYS2 #
Set through 'opam var'
msystem CLANG64 #
Set through 'opam var'
msystem-carch x86_64 #
Set through 'opam var'
msystem-chost x86_64-w64-mingw32 #
Set through 'opam var'
msystem-prefix /clang64 #
Set through 'opam var'
opam-version 2.2.0 #
The currently running opam version
os win32 #
Inferred from system
os-distribution msys2 #
Set through 'opam var'
os-family windows #
Inferred from system
os-version 10.0.19041 #
Inferred from system
root C:\Users\omerk\AppData\Local\opam #
The current opam root directory
switch playground #
The identifier of the current switch
sys-ocaml-arch #
Target architecture of the OCaml compiler present on your system
sys-ocaml-cc #
Host C Compiler type of the OCaml compiler present on your system
sys-ocaml-libc #
Host C Runtime Library type of the OCaml compiler present on your system
sys-ocaml-system #
Target system of the OCaml compiler present on your system
sys-ocaml-version #
OCaml version present on your system independently of opam, if any
sys-pkg-manager-cmd-msys2 C:\Users\omerk\AppData\Local\Programs\DkMLNative\tools\MSYS2\usr\bin\pacman.exe #
Set through 'opam var'
<><> Configuration variables from the current switch ><><><><><><><><><><><><><>
prefix C:\Users\omerk\AppData\Local\opam\playground
lib C:\Users\omerk\AppData\Local\opam\playground\lib
bin C:\Users\omerk\AppData\Local\opam\playground\bin
sbin C:\Users\omerk\AppData\Local\opam\playground\sbin
share C:\Users\omerk\AppData\Local\opam\playground\share
doc C:\Users\omerk\AppData\Local\opam\playground\doc
etc C:\Users\omerk\AppData\Local\opam\playground\etc
man C:\Users\omerk\AppData\Local\opam\playground\man
toplevel C:\Users\omerk\AppData\Local\opam\playground\lib\toplevel
stublibs C:\Users\omerk\AppData\Local\opam\playground\lib\stublibs
<><> Package variables ('opam var --package PKG' to show) <><><><><><><><><><><>
PKG:name # Name of the package
PKG:version # Version of the package
PKG:depends # Resolved direct dependencies of the package
PKG:installed # Whether the package is installed
PKG:enable # Takes the value "enable" or "disable" depending on whether the package is installed
PKG:pinned # Whether the package is pinned
PKG:bin # Binary directory for this package
PKG:sbin # System binary directory for this package
PKG:lib # Library directory for this package
PKG:man # Man directory for this package
PKG:doc # Doc directory for this package
PKG:share # Share directory for this package
PKG:etc # Etc directory for this package
PKG:build # Directory where the package was built
PKG:hash # Hash of the package archive
PKG:dev # True if this is a development package
PKG:build-id # A hash identifying the precise package version with all its dependencies
PKG:opamfile # Path of the current opam file
I enter bash simply with: > bash
Oops, sorry - from the Command Prompt thatâs just echo %PATH%
. When pasting the text, itâs worth putting it a codeblock which just means having three backticks in a row on a line before and after (I edited your last reply just to reformat that).
Ah - I can see from the report that youâve got a DkML installation - is that from a previous attempt?
I will guess that if you run where bash
, the first line is C:\msys64\usr\bin\bash.exe
? What does opam repo --set-default
show?
My PATH:
c:\program files (x86)\common files\oracle\java\javapath;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;c:\windows\system32\openssh\;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;c:\windows\system32\openssh\;c:\program files\microsoft sql server\130\tools\binn\;c:\program files\git\cmd;c:\program files\miktex\miktex\bin\x64\;c:\ffmpeg;c:\sox-14-4-2;c:\program files (x86)\pdftk\bin\;c:\mingw64\bin;c:\program files\dotnet\;c:\program files (x86)\smlnj\bin\;c:\program files\nvidia corporation\nvidia nvdlisr;c:\program files\tesseract-ocr;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\MATLAB\R2024a\bin;;C:\ProgramData\chocolatey\bin;C:\Users\omerk\AppData\Local\Programs\opam\bin;C:\Users\omerk\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\omerk\AppData\Local\Programs\Python\Python310\;C:\Users\omerk\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\omerk\AppData\Local\Programs\Python\Python39\;C:\Program Files (x86)\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files (x86)\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files (x86)\Microsoft Visual Studio\Common\Tools;C:\Program Files (x86)\Microsoft Visual Studio\VC98\bin;C:\Users\omerk\AppData\Local\Microsoft\WindowsApps;C:\Users\omerk\AppData\Local\GitHubDesktop\bin;C:\Users\omerk\AppData\Local\Programs\MiKTeX\miktex\bin\x64\;C:\Users\omerk\AppData\Local\Programs\Microsoft VS Code\bin;C:\msys64\ucrt64\bin;C:\msys64\usr\bin;C:\msys64\mingw64\bin;C:\Users\omerk\AppData\Roaming\npm;
I would guess that DkML
is installed from previous attempt.
â
C:\Users\omerk>where bash
c:\Windows\System32\bash.exe
C:\msys64\usr\bin\bash.exe
â
C:\Users\omerk> opam repo --set-default
<><> Default repository configuration (for newly created switches) ><><><><><><>
1 default https://opam.ocaml.org
Aha - I think I finally see! You ended up with both an âOCaml for Windowsâ .opam folder and you had a previous DkML root.
I think that if you delete / move somewhere else C:\Users\omerk\AppData\Local\opam
and re-run opam init
, youâll get many more menus asking how youâd like to set-up opam and you should then end up with an OCaml 5.2.0 switch at the end of opam init
. Iâm assuming that youâre not interested in keeping the DkML opam root around (the opam config report
suggests that that root hasnât had anything done with it).
I have deleted the opam folder.
What should I choose here? I think I have chosen 1st because 2nd option didnât work even though it was recommended.
How should opam obtain Unix tools?
> 1. Use tools found in PATH (MSYS2 installation at C:\msys64)
2. Automatically create an internal Cygwin installation that will be managed by opam (recommended)
3. Use MSYS2 installation found in C:\msys64
4. Use another existing Cygwin/MSYS2 installation
5. Abort initialisation
Iâm asking because I donât want to put you through all the hassle again . Also, the problems I have faced might have been a product of this choice here.
Either should work fine - although what actually happened when you picked option 2 (i.e. what do you mean by â2nd option didnât workâ?).
Donât worry at all - itâs really helpful to know about the problems, and we get bug reports and user experiences which we can feed into making it better in future (so I gain, too )