ocaml / setup-ocaml

GitHub Action for the OCaml programming language
https://ocaml.org/
MIT License
197 stars 38 forks source link

Windows setup fails with 2.0.4 #529

Closed hcarty closed 2 years ago

hcarty commented 2 years ago

The error is that there is a checksum error for one of the files in ocaml-config.

Example of a failed run: https://github.com/orx/ocaml-orx/runs/6644786129?check_suite_focus=true

Error output:

  D:\cygwin\bin\opam.exe switch create . --no-install --packages ocaml-variants.4.13.1+mingw64c

  <><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  [ocaml-variants.4.13.1+mingw64c] downloaded from https://github.com/fdopen/ocaml/releases/download/4.13.1-0/4.13.1+mingw64c.tar.xz

  <><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  -> installed base-bigarray.base
  -> installed base-threads.base
  -> installed base-unix.base
  -> installed ocaml-variants.4.13.1+mingw64c

  #=== ERROR while compiling ocaml-config.3 =====================================#
  Bad hash for D:/.opam/repo/upstream/packages/ocaml-config/ocaml-config.3/files/gen_ocaml_config.ml.in

  <><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  +- The following actions failed
  | - build ocaml-config 3
  +- 
  +- The following changes have been performed (the rest was aborted)
  | - install base-bigarray  base
  | - install base-threads   base
  | - install base-unix      base
  | - install ocaml-variants 4.13.1+mingw64c
  +- 
  # Run eval $(opam env --root=D:/.opam) to update the current shell environment
  Switch initialisation failed: clean up? ('n' will leave the switch partially installed) [Y/n] y
  Error: The process 'D:\cygwin\bin\opam.exe' failed with exit code 31
mlasson commented 2 years ago

I had the same issues on https://github.com/LexiFi/gen_js_api ; See build https://github.com/LexiFi/gen_js_api/runs/6654501298?check_suite_focus=true .

hcarty commented 2 years ago

This seems to impact 4.14.x as well - https://github.com/hcarty/ppx_defer/runs/6658713004?check_suite_focus=true

jonahbeckford commented 2 years ago

The problem is with Git's configurable handling of CRLF.

Adding a step for & "C:\Program Files\Git\bin\git.exe" config --system core.autocrlf input before setup-ocaml mitigates the issue. For example https://github.com/diskuv/dkml-c-probe/commit/8c1b4ab2eefe785723215835e70b7ceef8f342f5 ... essential bits are:

      - name: Hack Git CRLF for ocaml/setup-ocaml issue #529
        if: ${{ startsWith(matrix.os, 'windows-') }}
        run: |
          & "C:\Program Files\Git\bin\git.exe" config --system core.autocrlf input

      - uses: ocaml/setup-ocaml@v2

That is a hack of course. Correct answer is one of the following:

  1. setup-ocaml needs to set core.autocrlf itself when it installs Cygwin's git package (don't rely on whatever default GitHub Actions has ... which may change in the future)
  2. https://github.com/ocaml/opam-repository/blob/master/.gitattributes needs to add a rule for *.ml.in text eol=lf

Perhaps someone on the core OCaml team has some guidance which approach seems better.

eudoxia0 commented 2 years ago

@jonahbeckford This fixed my build, thank you!

mseri commented 2 years ago

While we wait for the fix, thanks for the hack!!!

dra27 commented 2 years ago

The workaround is good for now, yes! There was a PR for opam I did a few years back which worked by computing two checksums for these files, but it didn’t get merged… somewhere I have a revised “strategy” for it!

dra27 commented 2 years ago

The PR was https://github.com/ocaml/opam/pull/3407, but it was reverted prior to opam 2.0. I think the correct fix in opam is to specifically do the CRLF-agnostic hashing for git remotes only

smorimoto commented 2 years ago

I think https://github.com/ocaml/opam-repository/commit/166ce80c3d9774e5aa972ff9608f86fcf59a3693 fixed this. Or am I confusing something?

smorimoto commented 2 years ago

No, actually it was not. I just released v2.0.5 which reverts the changes I made in v2.0.4.

hcarty commented 2 years ago

I started a build and looks like Windows works again for ocaml-orx! Thank you @smorimoto! https://github.com/orx/ocaml-orx/runs/6711418597?check_suite_focus=true