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.
Likewise. opam version 2.1.4. --working-dir does nothing. The dependency is in the .opam file, but opam install . --deps-only --working-dir --with-test does not install the two dependencies I added. I added them to dune-project and ran dune build to generate the opam file, which it did correctly with the two dependencies I’d added to dune-project. But the opam install step says “Nothing to do”, opam list does not list them, and dune-build says they don’t exist.
I have the same problem with the latest opam and dune. I have the dependency (committed!) in my .opam file, but nonetheless when I run opam install . --deps-only it does not get installed. This is a really frustrating problem, and it has been an issue for years now. Any ideas on how to fix? It is only intermittently reproducible.
I have the same problem as Jon. I committed the modified opam file and the new decencies are installed when I run opam install. The --working-dir option has no effect. I tried opam clean but it didn’t help neither.
In addition, if I remove dependencies from the .opam file and uninstall the respective packages then these dependencies are still being installed when I run opam install . .
Where does opam look for the dependency information? It doesn’t seem to be the local .opam file.
I think I figured it out. It seems to be a ‘feature’ related to the pinning mechanism?
When I first run something like
opam install .
that will install a package pkg then pkg will get ‘pinned’. I can see pinned packages with
opam pin
When I run opam install . again then it will seemingly use the dependency information from that pinned package pkg instead of the info in pkg.opam. Runnning
opam pin remove pkg
will remove the pinned package and opam install . works (at least for me).