I’m trying to add a package that exists in a specific directory of a GitHub repository. The command I’m running (which is also the one noted in their docs) is this one:
I’ve resulted to pinning the package from a local copy of that repository, and that works fine, but I’m wondering what I’m missing to make the suggested command work.
Most likely, opam failed to inferred that your URL should be interpreted as the address to a (remote) git repository. Either one of the following should work:
I tried unpinning the local copy and then running the commands. I get the same error from both of those commands:
[ERROR] Could not synchronize ./_opam/.opam-switch/sources/bril from "git+https://github.com/sampsyo/bril/tree/master/bril-ocaml":
"/usr/bin/git fetch -q" exited with code 128 "fatal: repository 'https://github.com/sampsyo/bril/tree/master/bril-ocaml/' not found"
[ERROR] Error getting source from git+https://github.com/sampsyo/bril/tree/master/bril-ocaml:
- git+https://github.com/sampsyo/bril/tree/master/bril-ocaml
Perhaps I should mention that I am using a switch for this project. Thank you for the suggestion, any other ideas I could try?
Ah yeah, of course, the url you’ve specified is to (the github tree view of) a sub-directory, it is not a git repository in itself. I don’t know if you can opam pin it that way then…
There are a few options, depending on what workflow you plan on having with the package, but yes cloning + pinning at the right subpath with -k path should work.
Since the package builds with Dune, one alternative is to vendor it by copying the package anywhere inside your source tree (e.g. with a Git submodule in a vendors/ directory) and installing its dependencies. Dune will pick up the library automatically, and you can use (vendored_dirs <path>) to avoid accidentally running its tests / formatting its source code. This has the advantage of being somewhat easier to replicate in CI & avoiding Opam invocations if you ever want to modify the library.