Opam pin add: Error: I don't know about package XXX (passed through --only-packages)

Hello,

I’m facing a strange error when using opam pin. opam install-ing a package works fine, but opam pin add-ing an archive results in (here with package vlt but the error is the same with any package):

opam pin add https://github.com/codinuum/vlt/archive/v0.2.5.tar.gz
...
#=== ERROR while compiling vlt.0.2.5 ==========================================#
# context     2.5.1 | linux/x86_64 | ocaml-base-compiler.5.4.0 | pinned(https://github.com/codinuum/vlt/archive/v0.2.5.tar.gz)
# path        /personal/guesdon/.opam/5.4.0/.opam-switch/build/vlt.0.2.5
# command     /personal/guesdon/.opam/opam-init/hooks/sandbox.sh build dune build -p vlt -j 15 @install
# exit-code   1
# env-file    /personal/guesdon/.opam/log/vlt-139671-ec5925.env
# output-file /personal/guesdon/.opam/log/vlt-139671-ec5925.out
### output ###
# Error: I don't know about package vlt (passed through --only-packages)

And indeed, the directory /personal/guesdon/.opam/5.4.0/.opam-switch/build/vlt.0.2.5 only contains the dune _build directory, not any file from the archive. In a verbose log, it appears that opam runs rsync:

+ /usr/bin/rsync "-rLptgoDvc" "--exclude" ".git" "--exclude" "_darcs" "--exclude" ".hg" "--exclude" ".#*" "--exclude" "_opam*" "--exclude" "_build" "--delete" "--delete-excluded" "/tmp/opam-pin-cache-139671-415d73/a0a557e2dadf49e6/" "/tmp/opam-139671-7398b7"

Could the problem be that the destination directory of the rsync command is /tmp/opam-139671-7398b7 instead of /personal/guesdon/.opam/5.4.0/.opam-switch/build/vlt.0.2.5 ? And if so, do you have any idea why ?

I can provide a full log if needed.

That looks similar-ish to ocaml/opam#4977.
If i do opam pin add vlt https://github.com/codinuum/vlt/archive/v0.2.5.tar.gz, it works fine.

We haven’t had time to debug this yet but if you have some time to spare we could help you contribute if you wish to. The code for opam pin starts at src/client/opamCommands.ml:3498 (the inner pin function)

i’ve opened ocaml/opam#6999 to track this issue more precisely

Thanks for your answer. Indeed, when specifying the package name and not only the archive, it works. The problem is not the absence of .opam file in the archive, since the archive contains one.

I tried with previous versions of opam (2.4.1 and 2.5.0) and I have the same problem, so I think it is related to something on my machine (and of course “It worked before”).

I’ll investigate from the opam code next week.

Thanks. I do not use github any more, but I’ll tell you here if I found something (or even if I do not find anything).

We also have a mirror on codeberg if that helps: codeberg.org/ocaml/opam
We’ve opened it a few months ago and wanted to advertise it but health issues and subsequent delays in the next opam release made that that hasn’t happened yet, but soon.