According to the documentation of opam, command opam install . --deps-only --working-dir should install all the dependencies for me, but it didn’t do anything.
$ opam install . --deps-only --working-dir
$ dune build
File "lib/dune", line 4, characters 12-20:
4 | (libraries camomile))
^^^^^^^^
Error: Library "camomile" not found.
Hint: try:
dune external-lib-deps --missing @@default
$ dune external-lib-deps --missing @@default
Error: The following libraries are missing in the default context:
- camomile
Hint: try:
opam install camomile
Dune still wants me to install the dependencies manually.
Maybe there is some confusion here? Opam is looking at your *.opam file, not your dune files. So you need to have the correct dependencies specified in the Opam file.
Maybe try opam install . --deps-only --with-test --yes to install your dependencies.
I don’t use the --working-dir option but the docs don’t suggest it will do what you want.
-w, --working-dir
Whenever updating packages that are bound to a local,
version-controlled directory, update to the current working state
of their source instead of the last committed state, or the ref
they are pointing to. As source directory is copied as it is, if it
isn’t clean it may result on a opam build failure.This only affects
packages explicitly listed on the command-line.It can also be set
with $OPAMWORKINGDIR.
I’ve been thinking about why my CI always performs correctly, so I’m guessing it might have something to do with Git. I committed my changes on opam and run opam install again.
opam install . --deps-only --with-test
[petite.0.1.0] synchronised (git+file:///path/to/project#dev)
[petite] Installing new package description from upstream git+file:///path/to/project#dev
The following actions will be performed:
∗ install camomile 1.0.2
Do you want to continue? [Y/n] y
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><> 🐫
Processing 1/3: [camomile.1.0.2: dl]
⬇ retrieved camomile.1.0.2 (https://opam.ocaml.org/cache)
∗ installed camomile.1.0.2
Done.
--working-dir doesn’t seem to work the way I expected.
I still don’t understand some parts:
I’ve never used a package manager that is affected by a git commit before, what is the purpose of opam doing this? How could I get rid of this?
I’m using the dev Git branch for development. Is this the reason why opam is confused?
Anyway, at least my program is working now, thank you QAQ.