Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opam admin cache add --secondary-cache flag #4352

Closed
FMProof opened this issue Sep 11, 2020 · 4 comments · Fixed by #4384
Closed

Opam admin cache add --secondary-cache flag #4352

FMProof opened this issue Sep 11, 2020 · 4 comments · Fixed by #4384
Milestone

Comments

@FMProof
Copy link

FMProof commented Sep 11, 2020

This affects opam 2.0.7.

Given that many artifact URLs become obsolete over time, users requiring an offline clone of the opam repository need a way to fetch missing artifacts from other opam repository caches.

Many source URLs in the opam repository are becoming obsolete. For example, bitbucket has stopped serving archives of mercurial repositories. Running opam admin cache will never fully populate these entries even though the artifacts are still present on opam.ocaml.org in the cache.

I would like opam admin cache to add a flag --secondary-cache that names the url of an opam cache directory to use when directly fetching an artifact fails. This way, artifacts can be located when a URL cannot be resolved or a checksum is wrong.

@FMProof FMProof changed the title Opam admin cache Opam admin cache backup cache Sep 11, 2020
@FMProof FMProof changed the title Opam admin cache backup cache Opam admin cache add --secondary-cache flag Sep 11, 2020
@AltGr
Copy link
Member

AltGr commented Oct 8, 2020

I think adding the cache to ~/.opam/config or the repo file should do the trick. Can you check ?

If the latter works, ocaml/opam-repository#17355 should actually be enough to do the trick.

Note however that this approach means that the cache will always be hit before trying the upstream URL, which differs from what you were asking.

@FMProof
Copy link
Author

FMProof commented Oct 8, 2020

I appended the following to ~/.opam/config:

archive-mirrors: [ "https://opam.ocaml.org/cache" ]

This did not work. opam admin cache is not respecting this field.

I then checked the values in ~/.opam/repo/default/repo. It already contains this line:

archive-mirrors: "cache"

This means that opam knows about this cache location somewhere. However, it doesn't know that the git clone that I'm using is the same as this cache, so it doesn't look.

I then modified the mirrored repo directly, adding the opam URL to archive-mirrors

archive-mirrors: ["cache" "https://opam.ocaml.org/cache"]

This also did not work.

Was there another value you wanted me to try modifying somewhere?

It really appears that opam admin cache ignores other caches when downloading.

@AltGr
Copy link
Member

AltGr commented Oct 8, 2020

Thanks for testing!
It makes sense that ~/.opam/repo/default/repo doesn't work, since it is only expected to be used on the configured default repository, which opam doesn't know could be linked to your global git clone. ~/.opam/config should work always, though, as should defining the mirror in the local repo file; so indeed it seems it's not respected by opam admin, I'll see to it.

@FMProof
Copy link
Author

FMProof commented Oct 8, 2020

Thank you very much! I am constantly supporting offline development environments at my workplace, so a solution is very welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants