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

fix(pkg): handle empty package version #9177

Merged
merged 3 commits into from
Nov 22, 2023

Conversation

emillon
Copy link
Collaborator

@emillon emillon commented Nov 14, 2023

Fixes #9176

Due how we expand findlib variables, Some "" can come out of Findlib.Package.Version. We transform this to None before converting to Package_version.t.

@emillon
Copy link
Collaborator Author

emillon commented Nov 14, 2023

This is caused by defaulting to "" in here:

let get (t : t) var preds =
Option.map (String.Map.find t var) ~f:(fun r ->
Option.value ~default:"" (Rules.interpret r ~preds))
;;

But I suppose that we rely on this behavior somewhere.

@Alizter
Copy link
Collaborator

Alizter commented Nov 14, 2023

Where do we rely on this behaviour?

@rgrinberg
Copy link
Member

Do you think you could add a regression test for this?

@gridbugs
Copy link
Collaborator

Out of curiosity, how does a package trigger the bug fixed by this PR? Are they explicitly trying to find version "" of a package?

@emillon
Copy link
Collaborator Author

emillon commented Nov 15, 2023

Out of curiosity, how does a package trigger the bug fixed by this PR? Are they explicitly trying to find version "" of a package?

This happens when building the package DB. All versions are computed and they are being returned as "".

Where do we rely on this behaviour?
Do you think you could add a regression test for this?

I agree we have a testing blind spot here since modifying code in that area causes no failures. I'll try to think of a way to test that, that will probably mean writing META files by hand.

emillon added a commit to emillon/opam-repository that referenced this pull request Nov 16, 2023
CHANGES:

- Introduce new experimental odoc rules (ocaml/dune#8803, @jonjudlam)

- Cherry-pick ocaml/dune#9177 and ocaml/dune#9201 (@emillon)
Fixes ocaml#9176

Due how we expand findlib variables, `Some ""` can come out of
`Findlib.Package.Version`. We transform this to `None` before converting
to `Package_version.t`.

Signed-off-by: Etienne Millon <[email protected]>
@rgrinberg
Copy link
Member

Do we need a CHANGES entry for the original change?

@emillon
Copy link
Collaborator Author

emillon commented Nov 21, 2023

This is the first release we introduce Package_version.t so I can't think of another visible change besides dune-build-info.

@rgrinberg
Copy link
Member

so I can't think of another visible change besides dune-build-info.

Right, this is what I referred to. I would mention it.

@emillon
Copy link
Collaborator Author

emillon commented Nov 21, 2023

Ah do you mean for #9060? I'm not sure if it changes anything for users.
OTOH I'm wondering how we are going to tighten the Package_version.t if we want to make it completely equivalent to opam version numbers. We can add a versioned check in the future I suppose but I'm not sure it's a property of the dune project, strictly speaking.

@rgrinberg
Copy link
Member

We can start with that and just forbid invalid version in 4.0. I don't think anyone will care since such packages wouldn't be submittable to opam anyway

@emillon
Copy link
Collaborator Author

emillon commented Nov 21, 2023

Right, this is what I referred to. I would mention it.

Not sure if you've seen it, but I added a changelog entry for this. Do you think something is missing?

We can start with that and just forbid invalid version in 4.0. I don't think anyone will care since such packages wouldn't be submittable to opam anyway

I'm thinking of cases where the findlib metadata of dependencies (that do not use Dune) is not compatible with opam's format. These can slip through and might exist on opam (though I think we would have caught them in the alpha2 run), and would cause an issue when locking possibly.

@emillon
Copy link
Collaborator Author

emillon commented Nov 21, 2023

(I'm fine with not dealing with this right now)

@rgrinberg
Copy link
Member

Yes, I missed the CHANGES entry.

I'm thinking of cases where the findlib metadata of dependencies (that do not use Dune) is not compatible with opam's format. These can slip through and might exist on opam (though I think we would have caught them in the alpha2 run), and would cause an issue when locking possibly.

I've seen people get confused by versions in the META diverging from what opam is reporting. So if anything this is just an an unfortunate reality.

I agree, let's defer this for now.

@emillon emillon merged commit 98e294e into ocaml:main Nov 22, 2023
25 of 27 checks passed
@emillon emillon deleted the findlib-version-empty branch November 22, 2023 09:24
emillon added a commit to emillon/opam-repository that referenced this pull request Nov 22, 2023
CHANGES:

- Cherry-pick ocaml/dune#9215 and ocaml/dune#9009 (@emillon)

- dune-build-info: when `version=""` is found in a `META` file, we now return
  `None` as a version string (ocaml/dune#9177, @emillon)
emillon added a commit to emillon/opam-repository that referenced this pull request Nov 28, 2023
CHANGES:

- Introduce `$ dune ocaml doc` to open and browse documentation. (ocaml/dune#7262, fixes
  ocaml/dune#6831, @EmileTrotignon)

- `dune cache trim` now accepts binary byte units: `KiB`, `MiB`, etc. (ocaml/dune#8618,
  @Alizter)

- No longer force colors for OCaml 4.03 and 4.04 (ocaml/dune#8778, @rgrinberg)

- Introduce new experimental odoc rules (ocaml/dune#8803, @jonjudlam)

- Introduce the `runtest_alias` field to the `cram` stanza. This allows
  removing default `runtest` alias from tests. (@rgrinberg, ocaml/dune#8887)

- Do not ignore libraries named `bigarray` when they are defined in conjunction
  with OCaml 5.0 (ocaml/dune#8902, fixes ocaml/dune#8901, @rgrinberg)

- Dependencies in the copying sandbox are now writeable (ocaml/dune#8920, @rgrinberg)

- Absent packages shouldn't prevent all rules from being loaded (ocaml/dune#8948, fixes
  ocaml/dune#8630, @rgrinberg)

- Correctly determine the stanza of menhir modules when `(include_subdirs
  qualified)` is enabled (@rgrinberg, ocaml/dune#8949, fixes ocaml/dune#7610)

- Display cache location in Dune log (ocaml/dune#8974, @nojb)

- Re-run actions whenever `(expand_aliases_in_sandbox)` changes (ocaml/dune#8990,
  @rgrinberg)

- Rules that only use internal dune actions (`write-file`, `echo`, etc.) can
  now be sandboxed. (ocaml/dune#9041, fixes ocaml/dune#8854, @rgrinberg)

- Do not re-run rules when their location changes (ocaml/dune#9052, @rgrinberg)

- Correctly ignore `bigarray` on recent version of OCaml (ocaml/dune#9076, @rgrinberg)

- Add `test_` prefix to default test name in `dune init project` (ocaml/dune#9257, fixes
  ocaml/dune#9131, @9sako6)

- Add `coqdoc_flags` field to `coq` field of `env` stanza allowing the setting
  of workspace-wide defaults for `coqdoc_flags`. (ocaml/dune#9280, fixes ocaml/dune#9139, @Alizter)

- [coq rules] Be more tolerant when coqc --print-version / --config don't work
  properly, and fallback to a reasonable default. This fixes problems when
  building Coq projects with `(stdlib no)` and likely other cases. (ocaml/dune#8966, fix
  ocaml/dune#8958, @Alizter, reported by Lasse Blaauwbroek)

- Dune will now run at a lower framerate of 15 fps rather than 60 when
  `INSIDE_EMACS`. (ocaml/dune#8812, @Alizter)

- dune-build-info: when `version=""` is found in a `META` file, we now return
  `None` as a version string (ocaml/dune#9177, @emillon)

- Dune can now be built and installed on Haiku (ocaml/dune#8795, fix ocaml/dune#8551, @Alizter)

- Mark installed directories in `dune-package` files. This fixes `(package)`
  dependencies against packages that contain such directories. (ocaml/dune#8953, fixes
  ocaml/dune#8915, @emillon)
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

Successfully merging this pull request may close these issues.

Invalid Package_version.t
4 participants