Skip to content

Conversation

@jhjourdan
Copy link
Contributor

No description provided.

@jhjourdan
Copy link
Contributor Author

There is something very weird happening with host-system-msys: I placed this package as conflciting with unison, so that Opam should refuse to install Unison on the Mingw port. Instead, opam uninstalls this package and installq host-system-msvc, defeating the point of host-system-msys. This looks like a bug in host-system-msys to me.

@mseri
Copy link
Member

mseri commented Nov 5, 2025

@jmid what is the correct syntaxt to be uninstallable on mingw?

@jmid
Copy link
Member

jmid commented Nov 5, 2025

I had something similar happen: #28478 (comment) 🤷

My current understanding is that the host-system- packages are just regular opam packages, and hence not necessarily a good fit for conflicts. Polite ping @dra27 - do you agree?

Rather than conflicts you can use

  • available: os != "win32" to disable on (MSys2-MinGW/Cygwin-MinGW/Cygwinports) Windows, leaving "pure Cygwin"
  • available: os != "win32" | os-distribution != "msys2" to disable on only MSys2 or something like
  • available: os != "win32" | (os-distribution != "msys2" & os-distribution != "cygwin") to disable only on MSys2-MinGW and Cygwin-MinGW
  • ...

where we utilize the bottom table from here: https://github.com/ocaml/opam-repository/wiki/Depexts-os-distribution---os-family-values

@jhjourdan
Copy link
Contributor Author

What's the values of the variables for the msvc port?

@jhjourdan
Copy link
Contributor Author

The following did the trick:

available: (os != "win32" | host-system-msvc:installed)

Not particularly elegant.

@mseri
Copy link
Member

mseri commented Nov 5, 2025

Looks perfectly good to me :)
Thanks to both

@jmid
Copy link
Member

jmid commented Nov 6, 2025

The following did the trick:

available: (os != "win32" | host-system-msvc:installed)

Not particularly elegant.

The opam CI linter is failing with

Error in unison.2.53.8: error 34: Field 'available:' contains references to package-local variables. It should only be determined from global configuration variables: "host-system-msvc:installed"

I don't know how serious this is though. Is it "just" a bad-practice warning or does it mean that it is somehow broken to do so? 🤔

@mseri
Copy link
Member

mseri commented Nov 6, 2025

I don’t know, @rjbou or @kit-ty-kate what do you think?

@kit-ty-kate
Copy link
Member

The following did the trick:

available: (os != "win32" | host-system-msvc:installed)

mmh, how did you test this? Package variables aren't supposed to be evaluated in the available field (hence the lint error).

I've tried the following for good measure, just in case there is something wrong with the code:

opam-version: "2.0"
available: dune:installed

but i'm unable to install it even if dune is installed, as expected.

Comment on lines 20 to 27
available: (os != "win32" | host-system-msvc:installed)
depends: [
"ocaml" {>= "4.08"}
]
depopts: [
"lablgtk3" {>= "3.1.0"}
"ocamlfind"
"host-system-msvc"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like that would work instead, for example:

Suggested change
available: (os != "win32" | host-system-msvc:installed)
depends: [
"ocaml" {>= "4.08"}
]
depopts: [
"lablgtk3" {>= "3.1.0"}
"ocamlfind"
"host-system-msvc"
depends: [
"ocaml" {>= "4.08"}
"host-system-msvc" {os = "win32"}
]
depopts: [
"lablgtk3" {>= "3.1.0"}
"ocamlfind"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work. If I specify this, then opam simply uninstalls host-system-msys and installs host-system-msvc (at least on CI)...

@jhjourdan
Copy link
Contributor Author

Thanks. I did that change, let's see how it goes.

@jhjourdan
Copy link
Contributor Author

Cc @tleedjarv : again, I don't have a Windows machine at hand, and it looks like Unison refuses to build on the MinGW port. Since the build script explicitly mentions the MSVC port, I restricted Windows support to MSVC. Please tel me if this is ok with you.

@jhjourdan
Copy link
Contributor Author

Alright, I tried to disable unison-gui entirely on Windows (because it just seems not to work on Windows), and enable unison on every Windows port (including MSVC, MinGW, etc...). Let's see what CI says.

]
conflicts: [
"lablgtk3" {os = "win32"}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To address the parse error:

Warning:  Could not read file D:\opamroot\repo\default\packages\unison\unison.2.53.8\opam. skipping:
          At D:\opamroot\repo\default\packages\unison\unison.2.53.8\opam:29:0-29:1::
          Parse error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Where do you get these lints?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Somehow the "opam-ci" link disappeard for some time...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Where do you get these lints?

Click the Windows CI / build ... link
https://github.com/ocaml/opam-repository/actions/runs/19137212003/job/54692236076?pr=28851

  • then unfold the Install packages step
  • it is then written at the top:
<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
[default] synchronised from file://D:/a/opam-repository/opam-repository
Warning:  Could not read file D:\opamroot\repo\default\packages\unison\unison.2.53.8\opam. skipping:
          At D:\opamroot\repo\default\packages\unison\unison.2.53.8\opam:29:0-29:1::
          Parse error
Now run 'opam upgrade' to apply any package updates.
- Testing unison-gui.2.53.8
unison-gui.2.53.8 is not installable. Skip.

- Testing unison.2.53.8
unison.2.53.8 is not installable. Skip.

You can further unfold the CI log for each individual package.
That's where I could see unison.2.53.8 building and unison-gui.2.53.8 failing.

This kind of error could also have been caught by running opam lint path/to/opam/file locally first (not pointing any fingers here - there's a reason I started sometimes remembering to do so... 😅 )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Somehow the "opam-ci" link disappeard for some time...)

Yes, I've noticed too (both yesterday and today). I've notified @mtelvers

@jmid
Copy link
Member

jmid commented Nov 6, 2025

I'm not sure I understand the intent of limiting this to only MSVC on Windows.
From past CI logs the text-mode application unison seems to build under both Cygwin-MinGW and MSys2-MinGW (both using gcc I believe) - the GUI is another matter... 🤷
If the text-mode app compiles cleanly, then why disable it? 🤔

@jhjourdan
Copy link
Contributor Author

From past CI logs the text-mode application unison seems to build under both Cygwin-MinGW and MSys2-MinGW

Well, apparently not.

@jmid
Copy link
Member

jmid commented Nov 6, 2025

Well, apparently not.

Perhaps I am misunderstanding something. On commit 591613f I see both Windows workflows building unison but failing to build unison-gui. This was using nmake for both and also listing host-system-msvc as a dependency. I also share your impression that the latter may not have had a great effect - for one it did not trigger a MSVC rebuild of the compiler.

Looking at the package description for host-system-msvc:

This package is installed if the underlying OCaml compiler is one of the "MSVC"
native Windows ports of OCaml.

Precisely, this means `ocamlopt -config-var system` is equal to either `win32`
or `win64`.

This package may be used in depends or conflicts fields of dependent packages
to indicate either a requirement or an incompatibility with this OCaml port.

I know from a self-PR that system: mingw64 for both our MinGW (Cygwin+MSys2) workflows. So that package may indeed be broken. Looking some more at its contents:

conflict-class: "ocaml-host-system"
available: os = "win32"

there doesn't seem to be much preventing it from installing on an existing setup with system: mingw64.

That being said, it still appears as if unison can build without MSVC... 🤔

@jhjourdan
Copy link
Contributor Author

I posted a bug report on Unison for the build failure on MinGW: bcpierce00/unison#1164.

Let's see what happens. It may be the case that I have a quick answer...

@jhjourdan
Copy link
Contributor Author

Appart from that, CI is failing under FreeBSD. The issue is caused by a fialure to build Cairo (the FreeBSD package, it seems). I am even less a FreeBSD user than a Windows user, so I don't want to debug this.

Should I leave the FreeBSD issue as is, or should I disable the GUI on FreeBSD? It seems to be more a FreeBSD issue than an Opam/Unison issue.

@jmid
Copy link
Member

jmid commented Nov 6, 2025

It is fine to leave FreeBSD as is. These days it is failing more often than succeeding, so I believe it is a CI issue.
Polite ping @mtelvers
https://opam.ci.ocaml.org/github/ocaml/opam-repository/commit/1f124b19b35c73f12d3cf39b2f82e4e50967093b/variant/freebsd,freebsd-14.3-ocaml-4.14-amd64,unison-gui.2.53.8

+ /usr/local/bin/sudo "pkg" "install" "-y" "graphics/cairo" "gtk3"
- Updating FreeBSD repository catalogue...
- pkg: An error occurred while fetching package: Unknown error
- pkg: An error occurred while fetching package: Unknown error
- pkg: An error occurred while fetching package: Unknown error
- pkg: An error occurred while fetching package: Unknown error
- pkg: An error occurred while fetching package: Unknown error
- Unable to update repository FreeBSD
- Updating FreeBSD-kmods repository catalogue...
- [rosemary] Fetching data.pkg: .. done
- pkg: No signature found
- FreeBSD-kmods repository is up to date.
- Error updating repositories!
- The following 82 package(s) will be affected (of 0 checked):
- 
- New packages to be INSTALLED:
- 	adwaita-icon-theme: 47.0 [FreeBSD]
- 	adwaita-icon-theme-legacy: 46.2 [FreeBSD]
- 	at-spi2-core: 2.56.4 [FreeBSD]
- 	avahi-app: 0.8_6 [FreeBSD]
- 	cairo: 1.18.2,3 [FreeBSD]
[...]
- 	xkeyboard-config: 2.41_4 [FreeBSD]
- 	xorgproto: 2024.1 [FreeBSD]
- 
- Number of packages to be installed: 82
- 
- The process will require 394 MiB more space.
- 67 MiB to be downloaded.
- [rosemary] [1/82] Fetching duktape-lib-2.7.0_1.pkg: ...
- .
- ...... done
- pkg: cached package duktape-lib-2.7.0_1: missing or size mismatch, fetching from remote
- [rosemary] [2/82] Fetching duktape-lib-2.7.0_1.pkg: ....
- .
- .... done
- pkg: cached package duktape-lib-2.7.0_1: missing or size mismatch, cannot continue
- Consider running 'pkg update -f'
- [rosemary] [3/82] Fetching duktape-lib-2.7.0_1.pkg: .
- ........ done
- pkg: cached package duktape-lib-2.7.0_1: missing or size mismatch, fetching from remote
- [rosemary] [4/82] Fetching duktape-lib-2.7.0_1.pkg: ..
- ...
- ..... done
- pkg: cached package duktape-lib-2.7.0_1: missing or size mismatch, cannot continue
- Consider running 'pkg update -f'
[ERROR] System package install failed with exit code 3 at command:
            sudo pkg install -y graphics/cairo gtk3
[ERROR] These packages are still missing: graphics/cairo gtk3

@jhjourdan
Copy link
Contributor Author

Is it possible to get the log files of the opam build from the CI? I can get stdout/stderr from the CI, but the output is truncated by opam...

@jhjourdan jhjourdan changed the title Unison 2.53.8. [Draft] Unison 2.53.8. Nov 6, 2025
@jhjourdan jhjourdan changed the title [Draft] Unison 2.53.8. Unison 2.53.8. Nov 6, 2025
@tleedjarv
Copy link

Alright, I tried to disable unison-gui entirely on Windows (because it just seems not to work on Windows), and enable unison on every Windows port (including MSVC, MinGW, etc...). Let's see what CI says.

TUI/CLI (so unison) should build fine on all Windows ports. It's also possible to compile the GUI on all Windows ports but it requires some patching of the dependencies and/or may require some manual setup. You could see the upstream GHA workflow file for inspiration. The builds there use opam + make. I don't see why opam-only apporach wouldn't work just as well.

@jhjourdan jhjourdan marked this pull request as draft November 6, 2025 15:52
@jhjourdan
Copy link
Contributor Author

I'm trying to patch the sources of Unison to see if that fixes the issue with Msys.

@jhjourdan
Copy link
Contributor Author

I don't see why opam-only apporach wouldn't work just as well.

How should I patch the dependencies with an opam-only approach? I can apply a patch to unison, but I don't see how I could apply a patch to e.g., Cairo.

@tleedjarv
Copy link

I don't see why opam-only apporach wouldn't work just as well.

How should I patch the dependencies with an opam-only approach? I can apply a patch to unison, but I don't see how I could apply a patch to e.g., Cairo.

Right, maybe you can't.
Maybe then the patches can be incorporated to the relevant packages directly. Here are the tickets:
Chris00/ocaml-cairo#39
garrigue/lablgtk#165 (comment)
I don't see ocaml-cairo or lablgtk3 getting any new releases, so the patching would have to be done within opam-repository, I guess (I don't know how it works).

@jhjourdan
Copy link
Contributor Author

I opened actual PRs for these two issues. Let's see if the maintainers don't react.

My problems with patching in the opam package is that 1- they have not been validated and thoroughly tested in other platforms than Windows and 2- I don't know where to host the patches.

@jhjourdan jhjourdan marked this pull request as ready for review November 6, 2025 22:48
@jhjourdan
Copy link
Contributor Author

Ok, so I replaced the patch with bcpierce00/unison#1166, which should fix the issue on Windows.

@jhjourdan
Copy link
Contributor Author

That's ready to merge.

@jhjourdan
Copy link
Contributor Author

Actually, hold on: @gdt wants to do some cosmetic changes on the patch, and the hashes will change...

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants