Search code examples
gitmoduleocamlpublishopam

Opam publish fails due to wget retrieval failure (404)


Simply put, I have a library with a module. I can install it locally with opam install . in the local version of the GitHub repository without issue and use it just fine.

Following the instructions here, I created the corresponding .opam file, tested it using opam install . and tried using it via dune, and tagged and pushed the archive.

However, when I try to run opam publish, I get the following error:

[ERROR] Uncaught exception: OpamDownload.Download_fail(_, "Download command failed: \"/usr/local/bin/wget --content-disposition -t 3 -O
        /private/var/folders/zj/jsz2c_2x4blgtf_b14lfwl3r0000gn/T/opam-29567-5a61c5/archives/790f017e8273931983fa69cb4a5b6951-1.0.tar.gz.part https://github.com/[redacted]/[packageName]/archive/1.0.tar.gz -U opam/2.0.7\" exited with code 8
        \"2020-12-18 01:52:47 ERROR 404: Not Found.\"")

Here are the versions of various potentially-related packages:

  • wget: GNU Wget 1.20.3 built on darwin18.7.0.
  • opam: 2.0.7
  • dune: 2.7.1
  • git: git version 2.29.2
  • opam-publish: 2.0.2
  • gpatch: 2.7.6

Here is how my .opam file generally looks with some redactions as necessary:

opam-version: "2.0"
name: "example"
version: "1.0"
synopsis: "This is essentially what my .opam file looks like but with the text redacted"
description: """
packageExample is a framework that is used for the sole purpose of being an example. It
does not actually do anything, and it in fact does not even really exist. All that
references this framework is this example representation of it in this .opam file.
"""
maintainer: "[Redacted] <[[email protected]]>"
authors: "[Redacted] <[redacted]@gmail.com>"
homepage: "https://github.com/[redacted]/example"
dev-repo: "git+https://github.com/[redacted]/example.git"
bug-reports: "https://github.com/[redacted]/example/issues"
doc: "[redacted]"
depends: [
    "ocaml" {>= "4.08.1"}
    "dune" {>= "2.7.1"}
    "base-bytes"
    "base-unix"
]
build: [
    ["dune" "build" "-p" name "-j" jobs]
    ["dune" "runtest" "-p" name "-j" jobs] {with-test}
    ["dune" "build" "@doc" "-p" name "-j" jobs] {with-doc}
]

Solution

  • The answer was that the GitHub repository must be public for opam publish to work. Go figure.

    Also, the autogeneration of the token failed for some reason, so I had to manually generate one from https://github.com/settings/tokens and provide it.