Bad checksum error

I am trying to create a new opam switch with OCaml 4.06.0. I can successfully create a switch with the latest OCaml version. But I encountered bad checksum error when I created an old branch. My opam version 2.1.2. The log is shown below.

opam switch create 4.06.0

<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: [“ocaml-base-compiler” {= “4.06.0”} | “ocaml-system” {= “4.06.0”}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
[ERROR] Failed to get extra source “alt-signal-stack.patch” of ocaml-base-compiler.4.06.0: Bad checksum

#=== ERROR while fetching sources for ocaml-base-compiler.4.06.0 ==============#
OpamSolution.Fetch_fail(“https://github.com/ocaml/ocaml/commit/137a4ad167f25fe1bee792977ed89f30d19bcd74.patch (Bad checksum, expected sha256=be16234f213207c9f5c52919d3e13d5ba38ca1cf6b1dba24a7d9baf59de8560b)”)

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
:arrow_down: fetch ocaml-base-compiler 4.06.0
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray base
│ ∗ install base-threads base
│ ∗ install base-unix base
└─

I cannot reproduce the error. Did you check that this wasn’t a transient download failure?

I am not sure, but I can reproduce the error on three machines: my laptop and two servers.
I attach the logs from two servers, air01 and dai05. The versions opam of them are 2.1.2 and 2.0.5

zhangliao@dai-05:~$ opam switch create 4.06.0
[NOTE] It seems you have not updated your repositories for a while. Consider updating them with:
opam update
<><> Installing new switch packages <><><><><><><><><><><><><><><><><><><><><><>
Switch invariant: [“ocaml-base-compiler” {= “4.06.0”} | “ocaml-system” {= “4.06.0”}]

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
∗ installed base-bigarray.base
∗ installed base-threads.base
∗ installed base-unix.base
[ERROR] Failed to get extra source “alt-signal-stack.patch” of ocaml-base-compiler.4.06.0: Bad checksum

#=== ERROR while fetching sources for ocaml-base-compiler.4.06.0 ==============#
OpamSolution.Fetch_fail(“https://github.com/ocaml/ocaml/commit/137a4ad167f25fe1bee792977ed89f30d19bcd74.patch (Bad checksum, expected sha256=be16234f213207c9f5c52919d3e13d5ba38ca1cf6b1dba24a7d9baf59de8560b)”)

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
:arrow_down: fetch ocaml-base-compiler 4.06.0
└─
┌─ The following changes have been performed (the rest was aborted)
│ ∗ install base-bigarray base
│ ∗ install base-threads base
│ ∗ install base-unix base
└─

(base) zhangliao@air-01:~$ opam switch create 4.06.0
<><> Gathering sources ><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
[ocaml-base-compiler.4.06.0] downloaded from cache at https://opam.ocaml.org/cache
[ERROR] The sources of the following couldn’t be obtained, aborting:
- ocaml-base-compiler.4.06.0: Bad checksum

could it be that you are using outdated version of the opam repository? Are things getting better after a opam update?

I’m asking because in your case the expected sha256sum seems to be be16234f213207c9f5c52919d3e13d5ba38ca1cf6b1dba24a7d9baf59de8560b.

But if I check in my installation, I have this sha256sum c0c1c64bed4cc2413be21ce8bfe52bb9caff4d1bcd7e7a72f9bcb113c231bc91

$ opam show ocaml-base-compiler.4.06.0 --raw
opam-version: "2.0"
name: "ocaml-base-compiler"
version: "4.06.0"
synopsis: "Official 4.06.0 release"
maintainer: "platform@lists.ocaml.org"
authors: [
  "Xavier Leroy"
  "Damien Doligez"
  "Jacques Garrigue"
  "Didier Rémy"
  "Jérôme Vouillon"
]
license: "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception"
homepage: "https://ocaml.org"
bug-reports: "https://github.com/ocaml/opam-repository/issues"
depends: [
  "ocaml" {= "4.06.0" & post}
  "base-unix" {post}
  "base-bigarray" {post}
  "base-threads" {post}
]
conflict-class: "ocaml-core-compiler"
available: !(os = "macos" & arch = "arm64")
flags: compiler
setenv: CAML_LD_LIBRARY_PATH = "%{lib}%/stublibs"
build: [
  [
    "sed"
    "-ib"
    "-e"
    "s/opts=\"\"/opts=\"-Wno-implicit-function-declaration\"/"
    "config/auto-aux/hasgot"
  ] {os = "macos"}
  ["./configure" "-prefix" prefix "-with-debug-runtime"]
    {os != "openbsd" & os != "freebsd" & os != "macos"}
  [
    "./configure"
    "-prefix"
    prefix
    "-with-debug-runtime"
    "-cc"
    "cc -O2 -pipe"
    "-aspp"
    "cc -O2 -pipe -c"
  ] {os = "openbsd" | os = "freebsd" | os = "macos"}
  [make "world"]
  [make "world.opt"]
]
install: [make "install"]
patches: ["fix-gcc10.patch" "alt-signal-stack.patch"]
dev-repo: "git+https://github.com/ocaml/ocaml.git#4.06"
extra-files: ["fix-gcc10.patch" "md5=c9198adfe0c9d8e7e299b4f4fef5dfc5"]
url {
  src: "https://github.com/ocaml/ocaml/archive/4.06.0.tar.gz"
  checksum: "md5=4f3906e581181c5435078ffe3e485e3f"
}
extra-source "alt-signal-stack.patch" {
  src:
    "https://github.com/ocaml/ocaml/commit/137a4ad167f25fe1bee792977ed89f30d19bcd74.patch?full_index=1"
  checksum:
    "sha256=c0c1c64bed4cc2413be21ce8bfe52bb9caff4d1bcd7e7a72f9bcb113c231bc91"
}

If I download and check the file, the hash appears to be correct. Note that the ?full_index=1 is important. Without it the file has a different hash.

$ curl -L -O "https://github.com/ocaml/ocaml/commit/137a4ad167f25fe1bee792977ed89f30d19bcd74.patch?full_index=1"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6135  100  6135    0     0  18331      0 --:--:-- --:--:-- --:--:-- 18313
$ sha256sum 137a4ad167f25fe1bee792977ed89f30d19bcd74.patch 
c0c1c64bed4cc2413be21ce8bfe52bb9caff4d1bcd7e7a72f9bcb113c231bc91  137a4ad167f25fe1bee792977ed89f30d19bcd74.patch
1 Like

It seems indeed related to an old repository.
My lap and servers have installed some local opam packages, and there is some problem with opam update. After I remove the installed local packages, I can run opam update and create 4.06.0 switch.

Just to check something here, and my apologies if you already know this–but 4.06 is a very old version of the language. The latest version in the 4.x series is 4.14, and in the 5.x series 5.1. If you are not strongly tied to the old version, you might want to consider using one of the new versions.

Just for the history, the issue was ocaml-base-compiler.4.12.1 patch checksum failure · Issue #23837 · ocaml/opam-repository · GitHub (which was hopefully permanently fixed by adding ?full_index=1 to all the patch URLs)