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 lock does not include with-test dependencies even when those are installed #4170

Closed
anton-trunov opened this issue May 1, 2020 · 9 comments

Comments

@anton-trunov
Copy link

The documentation says:

  • {dev}, {with-test}, and {with-doc} filters are kept if all packages of a specific filters are installed in the switch. Versions are fixed and the same filter is on all dependencies that are added from them

I have ounit and patdiff marked as with-test and installed in my opam switch, but those don't make it into the locked file.

Here is a minimized version of my project's opam file:

opam-version: "2.0"
maintainer: "[email protected]"
depends: [
  "ocaml" {>= "4.07.1" & < "4.10~"}
  "dune" {build & >= "2.0"}
  "ounit" {with-test & (>= "2.0.8" & < "2.3~")}
  "patdiff" {with-test & (>= "v0.12.1" & < "v0.13~")}
]
synopsis: "Example demonstrating the issue"

I execute opam lock . and here is my opam.locked file:

opam-version: "2.0"
maintainer: "[email protected]"
depends: [
  "base-bigarray" {= "base"}
  "base-threads" {= "base"}
  "base-unix" {= "base"}
  "dune" {= "2.5.1"}
  "ocaml" {= "4.07.1"}
  "ocaml-base-compiler" {= "4.07.1"}
  "ocaml-config" {= "1"}
]
synopsis: "Example demonstrating the issue"
name: "package"
version: "dev"

As you can see the with-test dependencies are not in the locked file and when I try to install the locked dependencies I get the following:

$ opam install . --deps-only --locked
[WARNING] Lock file opam.locked is outdated, you may
          want to re-run opam lock:
          Dependencies present in opam file not in lock
          file:
            - patdiff
            - ounit

Nothing to do.

Here is the result of running opam config report:

# opam config report
# opam-version      2.0.7
# self-upgrade      no
# system            arch=x86_64 os=macos os-distribution=homebrew os-version=10.15.4
# solver            builtin-mccs+glpk
# install-criteria  -removed,-count[version-lag,request],-count[version-lag,changed],-changed
# upgrade-criteria  -removed,-count[version-lag,solution],-new
# jobs              7
# repositories      4 (http) (default repo at f3cca7bb)
# pinned            1 (git), 1 (version)
# current-switch    default
@rjbou
Copy link
Collaborator

rjbou commented May 1, 2020

This opam lock feature and its documentation is the behaviour of opam integrated lock command, that is present in 2.1.0~alpha. Is it from the opam lock online manpage ?

@anton-trunov
Copy link
Author

anton-trunov commented May 1, 2020

Is it from the opam lock online manpage ?

Yes, it was from an online manpage.

Is it not supported anymore? If it's not, is there a workaround? Thanks in advance.

@rjbou
Copy link
Collaborator

rjbou commented May 1, 2020

FWIK, It has never been supported in the opam lock plugin, it is a new feature in the 2.1.0.
As opam-lock doesn't support it, opam lock check shouldn't warn about not found test depeendencies... And no, there is no workaround to lock test dependencies in lock plugin, only depopts.
We should also add a note ine the online manpage that it is available since 2.1.0.

@rjbou
Copy link
Collaborator

rjbou commented Aug 5, 2020

Closing in favor to ocaml-opam/opam2web#188. Thanks!

@rjbou rjbou closed this as completed Aug 5, 2020
@yutopp
Copy link

yutopp commented Jan 6, 2021

(ref: AltGr/opam-lock#11)

@tsnobip
Copy link

tsnobip commented Jan 24, 2023

this is shame that opam-lock doesn't support this, it's quite convenient to setup a test environment. There's no evolution planned on this?

@kit-ty-kate
Copy link
Member

for whatever reason it seems to work just fine with with-doc but not with with-test. Looking at the code i think this in unintended (they should both work). I'll reopen

@kit-ty-kate kit-ty-kate reopened this Jan 24, 2023
@kit-ty-kate
Copy link
Member

Ah nevermind, my test setup was faulty. It is supported and works just fine. If you see a case where this is not supported please open a new issue. Sorry for the noise.

@tsnobip
Copy link

tsnobip commented Jan 25, 2023

indeed, I tested again, and with-test dependencies do get added to the lock file but not their pin-depends, so I opened an issue (#5428) for this use case.

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

No branches or pull requests

5 participants