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

Report error on invalid syntax for version constraint in opam file #4439

Closed
mjambon opened this issue Nov 18, 2020 · 3 comments · Fixed by #4443
Closed

Report error on invalid syntax for version constraint in opam file #4439

mjambon opened this issue Nov 18, 2020 · 3 comments · Fixed by #4443
Projects
Milestone

Comments

@mjambon
Copy link
Contributor

mjambon commented Nov 18, 2020

I mistakenly specified "lsp" {"1.1.0"} instead of "lsp" {= "1.1.0"} in an opam file for a project. No error was reported by either opam lint or opam install. It would be great if an error was reported, rather than the dependency being ignored silently.

The session below shows that lsp is not installed and that having "lsp" {"1.1.0"} as a dependency is like having nothing instead.

$ opam config report
# opam config report
# opam-version      2.0.5 
# self-upgrade      no
# system            arch=x86_64 os=linux os-distribution=ubuntu os-version=20.04
# 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              3
# repositories      1 (http) (default repo at ad125b9b)
# pinned            2 (git)
# current-switch    4.10.0

$ opam list | grep lsp

$ opam lint opam
/home/martin/tmp/report/opam: Passed.

$ opam install --deps-only .
Nothing to do.

$ cat opam
opam-version: "2.0"
name: "thing"
version: "0.0.0"
synopsis: "A a"
description: "A a"

maintainer: "x <x@example.com>"
authors: [ "x <x@example.com>" ]
license: "LGPL-2.1"
homepage: "https://example.com"
dev-repo: "git+https://github.com/example/foo"
bug-reports: "https://github.com/example/foo/issues"

depends: [
  "lsp" {"1.1.0"}
]

build: [make]
@rjbou
Copy link
Collaborator

rjbou commented Nov 19, 2020

This syntax is allowed as the constrained filter evaluates correctly {"true"}, or {"%{a-var}%"} when a-var is a boolean, it is the default otherwise (here false). But yes, opam should at least warn on this kind of syntax when it is not a bool nor a variable.

@rjbou rjbou moved this from To do to In Progress in Opam 2.1.x Nov 20, 2020
Opam 2.1.x automation moved this from In Progress to Done Dec 3, 2020
@rjbou
Copy link
Collaborator

rjbou commented Dec 3, 2020

Added a lint warning #66. Thanks for the report

@mjambon
Copy link
Contributor Author

mjambon commented Dec 3, 2020

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Opam 2.1.x
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants