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

generate_opam_files seems broken in 2.0 #2927

Closed
shonfeder opened this issue Nov 27, 2019 · 10 comments · Fixed by #2946
Closed

generate_opam_files seems broken in 2.0 #2927

shonfeder opened this issue Nov 27, 2019 · 10 comments · Fixed by #2946
Labels

Comments

@shonfeder
Copy link
Collaborator

I have not been able to generate opam files from dune files in 2.0. Here is a minimal example that works to generate an opam file with dune 1.11.4 but does not lead to a generated opam file for dune 2.0:

(lang dune 1.11)
(name foo)
(homepage https://my.home.page)

(generate_opam_files true)

(package
 (name foo)
 )

I'm guessing we also need tests to guard against this regression in the future.

@ghost
Copy link

ghost commented Nov 27, 2019

I just gave this a try and it worked for me. How are you calling dune?

@shonfeder
Copy link
Collaborator Author

Oh! Maybe something to do with my environment then.. I am simply calling dune build in both cases...

I can try again on a fresh switch, and see if I can get some verbose output to help explain what's going on.

@shonfeder
Copy link
Collaborator Author

Argh.. frustrating. I can't reproduce on a fresh switch. I thought I'd tried that explicitly before opening this, but I must have had some state complicating things. If I figure out how to reproduce this, I'll reopen. In the meantime, sorry for the noise and thanks for your quick feedback.

@ghost
Copy link

ghost commented Nov 27, 2019

No worries, this kind of things has happened to me as well in the past. One way to be sure it's reproducible is to add a test case to the dune test suite since these are quite well sandboxed. We use a custom version of cram tests so they are easy to write. Just add a directory with a run.t file in test/blackbox-tests/test-cases, run make test && make promote once to generate the dune boilerplate and then dune runtest (or dune @<name-of-the-test>) to run the test.

@shonfeder
Copy link
Collaborator Author

Thanks for the tip, @diml. I'll walk through this next time! In fact, do you think it would be helpful to supply guidance on creating these kinds of test cases in the issue submission template for this repo?

(If you think this would be useful, but don't have bandwidth to write it up, I'm happen to open a draft PR with an issue template summarizing your points here (and the info in HACKING.md).)

@ghost
Copy link

ghost commented Nov 28, 2019

Yes! That would definitely be helpful. If issues could come with a reproduction case we could just merge, that would definitely make things easier.

A PR for this would be welcome :)

@kit-ty-kate
Copy link
Member

kit-ty-kate commented Nov 28, 2019

I have a similar problem, dune build generates an opam file, but as soon as change to (lang dune 2.0) nothing gets updated anymore (removing the opam file doesn't help, changing the fields defined in the dune-project doesn't help either).

Also dune --version gives me:

$ dune --version
n/a

Reproduced with something like:

$ git clone https://github.com/ocaml-doc/octavius.git
$ cd octavius
$ # change something in the dune-project file
$ dune build
$ git diff
# an actual diff in the opam file
$ # change from (lang dune 1.11) to (lang dune 2.0)
$ change another field
$ git diff
# didn't change the opam file at all

Could this be reopened? Else I'll create a new issue.

@kit-ty-kate
Copy link
Member

oh, I got it to work, but only if I call dune with -p <package>. Is this an expected change in dune 2.0?

@shonfeder
Copy link
Collaborator Author

shonfeder commented Nov 28, 2019

Ahha! So I'm not crazy. Thanks for updating with with reproduction steps, @kit-ty-kate. I think this is also what I had done, updating from 1.11 to 2.0 on an existing project. I wonder if something is getting cached in the _build dir that's interfering with opam file generation? I don't think I tried a clean rebuild in between updates. (Currently, I've just pinned 1.11 to get WIP done, but may poke at this again this weekend if I get a chance.)

oh, I got it to work, but only if I call dune with -p . Is this an expected change in dune 2.0?

Before I opened this ticket I checked the changelog for some sign of breaking changes to opam file generation, and didn't find anything. Moreover, iirc, on a fresh project that starts off using dune 2.0, it seems the file generation is working as expected.

(I noticed the --version bug too, but saw there was a ticket open already, and I think it's been closed dy #2929.)

@shonfeder shonfeder reopened this Nov 28, 2019
@ghost
Copy link

ghost commented Dec 3, 2019

Alright, I understand what's happening:

  • the default target when none is specified is @@default (alias "default", non-recursive), unless -p is given as it implies --default-target @install
  • with (lang dune 1.x), unless explicitly defined alias "default" maps to alias "install"
  • with (lang dune 2.x), unless explicitly defined alias "default" maps to alias "all"
  • alias "install" depends on the opam files
  • alias "all" doesn't depend on the opam files (this is the bug)

That explains the various behaviours observed. And indeed, if you do dune build octavius.opam or dune build @install, then the opam file does get updated.

@ghost ghost added the bug label Dec 3, 2019
rgrinberg added a commit to rgrinberg/opam-repository that referenced this issue Feb 15, 2020
…lugin, dune-private-libs and dune-glob (2.3.0)

CHANGES:

- Improve validation and error handling of arguments to `dune init` (ocaml/dune#3103, fixes
  ocaml/dune#3046, @shonfeder)

- `dune init exec NAME` now uses the `NAME` argument for private modules (ocaml/dune#3103,
  fixes ocaml/dune#3088, @shonfeder)

- Avoid linear walk to detect children, this should greatly improve
  performance when a target has a large number of dependencies (ocaml/dune#2959,
  @ejgallego, @aalekseyev, @Armael)

- [coq] Add `(boot)` option to `(coq.theories)` to enable bootstrap of
  Coq's stdlib (ocaml/dune#3096, @ejgallego)

- [coq] Deprecate `public_name` field in favour of `package` (ocaml/dune#2087, @ejgallego)

- Better error reporting for "data only" and "vendored" dirs. Using these with
  anything else than a strict subdirectory or `*` will raise an error. The
  previous behavior was to just do nothing  (ocaml/dune#3056, fixes ocaml/dune#3019, @voodoos)

- Fix bootstrap on bytecode only switches on windows or where `-j1` is set.
  (ocaml/dune#3112, @xclerc, @rgrinberg)

- Allow `enabled_if` fields in `executable(s)` stanzas (ocaml/dune#3137, fixes ocaml/dune#1690
  @voodoos)

- Do not fail if `ocamldep`, `ocamlmklib`, or `ocaml` are absent. Wait for them
  to be used to fail (ocaml/dune#3138, @rgrinberg)

- Introduce a `strict_package_deps` mode that verifies that dependencies between
  packages in the workspace are specified correctly. (@rgrinberg, ocaml/dune#3117)

- Make sure the `@all` alias is defined when no `dune` file is present
  in a directory (ocaml/dune#2946, fix ocaml/dune#2927, @diml)
mgree pushed a commit to mgree/opam-repository that referenced this issue Feb 19, 2020
…lugin, dune-private-libs and dune-glob (2.3.0)

CHANGES:

- Improve validation and error handling of arguments to `dune init` (ocaml/dune#3103, fixes
  ocaml/dune#3046, @shonfeder)

- `dune init exec NAME` now uses the `NAME` argument for private modules (ocaml/dune#3103,
  fixes ocaml/dune#3088, @shonfeder)

- Avoid linear walk to detect children, this should greatly improve
  performance when a target has a large number of dependencies (ocaml/dune#2959,
  @ejgallego, @aalekseyev, @Armael)

- [coq] Add `(boot)` option to `(coq.theories)` to enable bootstrap of
  Coq's stdlib (ocaml/dune#3096, @ejgallego)

- [coq] Deprecate `public_name` field in favour of `package` (ocaml/dune#2087, @ejgallego)

- Better error reporting for "data only" and "vendored" dirs. Using these with
  anything else than a strict subdirectory or `*` will raise an error. The
  previous behavior was to just do nothing  (ocaml/dune#3056, fixes ocaml/dune#3019, @voodoos)

- Fix bootstrap on bytecode only switches on windows or where `-j1` is set.
  (ocaml/dune#3112, @xclerc, @rgrinberg)

- Allow `enabled_if` fields in `executable(s)` stanzas (ocaml/dune#3137, fixes ocaml/dune#1690
  @voodoos)

- Do not fail if `ocamldep`, `ocamlmklib`, or `ocaml` are absent. Wait for them
  to be used to fail (ocaml/dune#3138, @rgrinberg)

- Introduce a `strict_package_deps` mode that verifies that dependencies between
  packages in the workspace are specified correctly. (@rgrinberg, ocaml/dune#3117)

- Make sure the `@all` alias is defined when no `dune` file is present
  in a directory (ocaml/dune#2946, fix ocaml/dune#2927, @diml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants