ocaml / opam

opam is a source-based package manager. It supports multiple simultaneous compiler installations, flexible package constraints, and a Git-friendly development workflow.
https://opam.ocaml.org
Other
1.23k stars 351 forks source link

opam 2.2.0 beta1 compile and install old ocaml version(4.11.0) failed on windows. #5873

Open fenginsc opened 6 months ago

fenginsc commented 6 months ago

I'm trying to use the latest opam 2.2.0 beta1 and have successfully installed ocaml 5.0.0 and ocaml 5.1.0. The repository https://github.com/dra27/opam-repository#windows-5.0 is used. I also tried using the https://github.com/fdopen/opam-repository-mingw.git#opam2 repository and successfully compiled and installed ocaml version 4.12.0 - 4.14.0. But I failed to compile and install an older version of ocaml 4.11.0, is this normal? Or am I missing some installation dependency?

>opam switch create ocaml.4.11.0 --package=ocaml-variants.4.11.0+mingw64

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: ["ocaml-variants" {= "4.11.0+mingw64"}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
* installed base-bigarray.base
* installed base-threads.base
* installed base-unix.base
▼ retrieved ocaml-variants.4.11.0+mingw64  (cached)
[ERROR] The compilation of ocaml-variants.4.11.0+mingw64 failed at "make SHELL=/bin/dash -j3
        world.opt".

#=== ERROR while compiling ocaml-variants.4.11.0+mingw64 ======================#
# context     2.2.0~beta1 | win32/x86_64 |  | git+https://github.com/fdopen/opam-repository-mingw.gi
t#opam2
# path        ~\AppData\Local\opam\ocaml.4.11.0\.opam-switch\build\ocaml-variants.4.11.0+mingw64
# command     ~\AppData\Local\opam\.cygwin\root\bin\make.exe SHELL=/bin/dash -j3 world.opt
# exit-code   2
# env-file    ~\AppData\Local\opam\log\ocaml-variants-7884-26640c.env
# output-file ~\AppData\Local\opam\log\ocaml-variants-7884-26640c.out
### output ###
# [...]
# ../boot/ocamlrun ../ocamlc -strict-sequence -absname -w +a-4-9-41-42-44-45-48 -g -warn-error A -bi
n-annot -nostdlib -safe-string -strict-formats   -c camlinternalMod.ml
# ../boot/ocamlrun ../ocamlc -strict-sequence -absname -w +a-4-9-41-42-44-45-48 -g -warn-error A -bi
n-annot -nostdlib -safe-string -strict-formats   -o stdlib__oo.cmo -c oo.ml
# ../boot/ocamlrun ../ocamlc -a -o stdlib.cma camlinternalFormatBasics.cmo stdlib.cmo stdlib__pervas
ives.cmo stdlib__seq.cmo stdlib__option.cmo stdlib__result.cmo stdlib__bool.cmo stdlib__char.cmo std
lib__uchar.cmo stdlib__sys.cmo stdlib__list.cmo stdlib__bytes.cmo stdlib__string.cmo stdlib__unit.cm
o stdlib__marshal.cmo stdlib__obj.cmo stdlib__array.cmo stdlib__float.cmo stdlib__int.cmo stdlib_[..
.]
# make[5]: Leaving directory '/cygdrive/c/Users/fenginsc/AppData/Local/opam/ocaml.4.11.0/.opam-switc
h/build/ocaml-variants.4.11.0+mingw64/stdlib'
# make[4]: Leaving directory '/cygdrive/c/Users/fenginsc/AppData/Local/opam/ocaml.4.11.0/.opam-switc
h/build/ocaml-variants.4.11.0+mingw64'
# make[3]: *** [Makefile:162: coreall] Error 2
# make[3]: Leaving directory '/cygdrive/c/Users/fenginsc/AppData/Local/opam/ocaml.4.11.0/.opam-switc
h/build/ocaml-variants.4.11.0+mingw64'
# make[2]: *** [Makefile:168: core] Error 2
# make[2]: Leaving directory '/cygdrive/c/Users/fenginsc/AppData/Local/opam/ocaml.4.11.0/.opam-switc
h/build/ocaml-variants.4.11.0+mingw64'
# make[1]: *** [Makefile:221: opt.opt] Error 2
# make[1]: Leaving directory '/cygdrive/c/Users/fenginsc/AppData/Local/opam/ocaml.4.11.0/.opam-switc
h/build/ocaml-variants.4.11.0+mingw64'
# make: *** [Makefile:283: world.opt] Error 2

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build ocaml-variants 4.11.0+mingw64
└─
┌─ 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.4.11.0') do @%i to update the current shell
environment
Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [y/n]

If opam 2.2.0 is officially released is there no need for these third party repositories? Then it seems will be easier to install and use ocaml on windows in the future!

kit-ty-kate commented 6 months ago

Can you show the full error message (from the file in C:\Users\<your username>\AppData\Local\opam\log\ocaml-variants-7884-26640c.out) ?

Otherwise I'm not sure what is the state of the pre 4.12 compilers in the temporary repositories. cc @dra27

If ocam2.2.0 is officially released is there no need for these third party repositories? Then it seems will be easier to install and use ocaml on windows in the future!

Yes, the work to make the default opam-repository compatible is ongoing and there will indeed be no need for external repositories once 2.2.0 is out.

fenginsc commented 6 months ago

Can you show the full error message (from the file in C:\Users\\AppData\Local\opam\log\ocaml-variants-7884-26640c.out) ?

Yes, I uploaded the file directly since it is very long. ocaml-variants-7884-26640c.zip

kit-ty-kate commented 6 months ago
../boot/ocamlrun ../boot/ocamlc -g -nostdlib -I ../boot -use-prims ../runtime/primitives -I .. -c -absname -w +a-4-9-41-42-44-45-48 -strict-sequence -warn-error A -principal -safe-string -strict-formats -bin-an     not -I ../utils -I ../parsing -I ../typing -I ../bytecomp -I ../middle_end -I ../middle_end/closure -I ../middle_end/flambda -I ../middle_end/flambda/base_types -I ../driver -I ../toplevel -I ../file_formats -I      ../lambda - ocamlmklibconfig.ml
File "C:\Users\fenginsc\AppData\Local\opam\ocaml.4.11.0\.opam-switch\build\ocaml-variants.4.11.0+mingw64\tools\ocamlmklibconfig.ml", line 1, characters 16-18:
1 | let bindir = "C:\Users\fenginsc\AppData\Local\opam\ocaml.4.11.0/bin"
                    ^^
Error (warning 14): illegal backslash escape in string.

ah yes, that sounds like a bug in the configure script of the compiler that might have to be patched. I'm not sure if the plan to bring the compilers to opam-repository include patching OCaml < 4.12 though. In the first phase, I believe (I'm not sure though) that only 4.13 and up will be covered.

fenginsc commented 6 months ago
../boot/ocamlrun ../boot/ocamlc -g -nostdlib -I ../boot -use-prims ../runtime/primitives -I .. -c -absname -w +a-4-9-41-42-44-45-48 -strict-sequence -warn-error A -principal -safe-string -strict-formats -bin-an     not -I ../utils -I ../parsing -I ../typing -I ../bytecomp -I ../middle_end -I ../middle_end/closure -I ../middle_end/flambda -I ../middle_end/flambda/base_types -I ../driver -I ../toplevel -I ../file_formats -I      ../lambda - ocamlmklibconfig.ml
File "C:\Users\fenginsc\AppData\Local\opam\ocaml.4.11.0\.opam-switch\build\ocaml-variants.4.11.0+mingw64\tools\ocamlmklibconfig.ml", line 1, characters 16-18:
1 | let bindir = "C:\Users\fenginsc\AppData\Local\opam\ocaml.4.11.0/bin"
                    ^^
Error (warning 14): illegal backslash escape in string.

ah yes, that sounds like a bug in the configure script of the compiler that might have to be patched. I'm not sure if the plan to bring the compilers to opam-repository include patching OCaml < 4.12 though. In the first phase, I believe (I'm not sure though) that only 4.13 and up will be covered.

illegal backslash escape in string. This error, if it is so common, I think it can be fixed uniformly, it should be unix-like system use /, while windows use \ cause, now how do I manually fix this error, try to see if it can be compiled properly?

dra27 commented 6 months ago

Not the most helpful of answers for now, but: