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

Package management should Ignore unused opam files when pinning #11276

Open
giltho opened this issue Jan 8, 2025 · 4 comments
Open

Package management should Ignore unused opam files when pinning #11276

giltho opened this issue Jan 8, 2025 · 4 comments

Comments

@giltho
Copy link

giltho commented Jan 8, 2025

This is feedback on the dune package management preview.

I have a file a project that pins another project, but it fails to build with Error: unexpected version because of some empty but unused opam files in the project.

It works after just adding one line to the relevant opam files. See rems-project/cerberus#817

@giltho giltho changed the title Ignore unused opam files when pinning Package management should Ignore unused opam files when pinning Jan 8, 2025
@rgrinberg
Copy link
Member

Thanks. Dune can infer projects from one of two sources:

  1. The project file
  2. The .opam files

The project file doesn't define any packages so dune goes for 2. AFAIK, an opam file with the version incantation is invalid. So I don't think there's anything we can do here.

@rgrinberg
Copy link
Member

Can you post your pins stanza? Maybe we can make the loading a little lazier.

@giltho
Copy link
Author

giltho commented Jan 9, 2025

I deleted that branch but I think it was simply

(pin
 (package
  (name cerberus-lib))
 (url
  "git+https://github.com/giltho/cerberus#6316f8f46dd8d6b207b8669c6ec082f78032e538"))

Yeah, I kind of understand that, ideally, all opam files should be correct. But empty opam files exist in many places because people don't generate them from dune-projects and dune refuses to build public modules without a corresponding opam file.

One or both of the following could be done:

  • newer versions of dune could require the opam file to be valid (i.e. at least contain the version) in order to compile a public module, and if not issue at least a warning.
  • If an opam file is detected to be empty, dune can just load use the default "empty" opam file that only contains 'opam-version: "2.0"'. It'd be a wrapper around the current function that loads the opam file, even if it's not pretty.

I do understand if option 2 is not desirable, and I can see that it doesn't appear, but on the issue now, but I clicked "Feature request" and not "Bug report" when I created this issue. I don't believe this is a bug, the current behaviour is acceptable, but it is worth flagging

@Leonidas-from-XIV
Copy link
Collaborator

AFAIK, an opam file with the version incantation is invalid.

Yes, that's true. The shortest valid OPAM file is

opam-version: "2.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants