Skip to content

Vendor cmdliner 1.3.0 as opam-core.cmdliner#6755

Merged
kit-ty-kate merged 1 commit intoocaml:masterfrom
kit-ty-kate:vendor-cmdliner
Nov 7, 2025
Merged

Vendor cmdliner 1.3.0 as opam-core.cmdliner#6755
kit-ty-kate merged 1 commit intoocaml:masterfrom
kit-ty-kate:vendor-cmdliner

Conversation

@kit-ty-kate
Copy link
Copy Markdown
Member

@kit-ty-kate kit-ty-kate commented Oct 26, 2025

The module name is renamed to OpamCmdliner to allow end-users of the opam libraries to use upstream cmdliner. The library is now also wrapped instead of unwrapped for the same reason.

The src/core/cmdliner/vendor.sh script allows us to show and make sure ourselves of the changes between upstream cmdliner and our vendored version.

Fixes #6425
Backported in 2.5 via #6756

@dbuenzli
Copy link
Copy Markdown
Contributor

Note that unless I did not read this well, this will prevent people from linking cmdliner and opam libraries.

I honestly have no idea why you decided to make your life so complicated. There are reasonable and simple workarounds that allow you to use cmdliner 2.0.0 directly.

@dbuenzli
Copy link
Copy Markdown
Contributor

There are reasonable and simple workarounds that allow you to use cmdliner 2.0.0 directly.

I'm just going to mention them because I'm not sure you got them.

  1. You can invoke you evaluation function with an env function that returns Some "true" on "CMDLINER_LEGACY_PREFIXES" and behave as Sys.getenv_opt otherwise (or whatever you inject if you use this). This will make your CLI behave exactly as it is now except for one case: Arg.enum value specification.
  2. If you think that the exception of 1. is too widespread you can do a Unix.putenv with the corresponding variable set.

@dbuenzli
Copy link
Copy Markdown
Contributor

dbuenzli commented Oct 26, 2025

2. If you think that the exception of 1. is too widespread you can do a Unix.putenv with the corresponding variable set.

I understand the reluctance to putenv so there is the obvious:

  1. Provide your own Arg.enum with the old behaviour which is not black magic.

Note that 1. + 3. gives you exactly what you asked for in this comment.

## VCS

## Build
* opam no longer depends on `cmdliner` [#6755 @kit-ty-kate - fix #6425]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* opam no longer depends on `cmdliner` [#6755 @kit-ty-kate - fix #6425]
* opam no longer depends on `cmdliner`. It is now vendored to avoid version clash and more fine grained . [#6755 @kit-ty-kate - fix #6425]

Proposal to be more precise on the how & why

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think we have to do this here. The blog post is the right place for explanations

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

and release notes. But ok to add it at that moment, we just need to remember

@@ -0,0 +1,21 @@
#!/bin/sh
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Where this file is used ?
It needs more documentation & if it is only for the first vendoring (from what i read), it's better to store it in shell/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is used for first vendoring and in the future (or now) to have a quick way of showing what has changed (or make sure nothing has changed) compared to upstream 1.3.0. I've moved it to shell/

@dbuenzli
Copy link
Copy Markdown
Contributor

dbuenzli commented Nov 7, 2025

Is it possible to discuss the opportunity of not doing this? Or at least have a public discussion on why you are doing this?

I would really like to have non utterly broken completion scripts for opam. I refrained from filing issues because I thought that cmdliner 2 would help you fix that. But if you prefer I can flood you with them.

In my opinion the course of action here is creating technical debt for the project (assuming you want to continue using cmdliner), promotes software bloat and is not in favour of opam end users who would likely prefer great completion than prefix specification for a tool they don't operate day to day or only on a very restricted subset.

@kit-ty-kate
Copy link
Copy Markdown
Member Author

Note that unless I did not read this well, this will prevent people from linking cmdliner and opam libraries.

dune wraps libraries by default, so modules like Cmdliner_arg are in fact named OpamCmdliner__Cmdliner_arg but accessible as Cmdliner_arg locally, allowing us to avoid renaming every call to the modules. See (wrapped ...) in the dune documentation

I honestly have no idea why you decided to make your life so complicated. There are reasonable and simple workarounds that allow you to use cmdliner 2.0.0 directly.

This is really not complicated, this took me 30mins to make and is quite straightforward. We don't need the new features of 2.0.0, and quite the opposite, upgrading to 1.3.0 minus the deprecation to make it compatible with 2.0.0 is quite a bit more work in itself as this PR shows.

dbuenzli/cmdliner#200 announced the removal of the CMDLINER_LEGACY_PREFIXES workaround in 3.0.0 so we're simply thinking ahead. On a more personal note, i personally think this change is quite user-hostile and this lost my trust to any future change that you might make in cmdliner. I personally think cmdliner 2.0.0 should've been a separate new cmdliner2 library or something like that.

Note that 1. + 3. gives you exactly what you asked for in this comment.

I don't think it does. The comment was asking for a tangible OCaml expression to ensure that if the feature suddenly disappears, the build would fail. Instead, with the environment variable, the build would continue to succeed but things would now break at runtime.

Note that vendoring this doesn't mean we can't go back to using upstream cmdliner in the future, as long as we're not adding our own patch on top of it, it will be as easy to remove the vendor as it was to create it. Maybe we will decide to stop supporting prefixes and have a proper alias system for shorter names in the future for opam 3.x but we would at least like our command line interface to remain stable for the remaining of opam 2.x.

@kit-ty-kate
Copy link
Copy Markdown
Member Author

But if you prefer I can flood you with them.

Please do, it's great to know in any case

@rjbou
Copy link
Copy Markdown
Collaborator

rjbou commented Nov 7, 2025

Besides, as mentioned in the issue #6425 (comment), Fedora packaging is blocked because of the constraint on cmdliner.1.3. Vendoring it now, for the release is a quick way to resolve this issue. As mentioned Kate, we can choose in the future to do in another way.

kit-ty-kate added a commit to ocaml-opam/opam-rt that referenced this pull request Nov 7, 2025
@dbuenzli
Copy link
Copy Markdown
Contributor

dbuenzli commented Nov 7, 2025

dbuenzli/cmdliner#200 announced the removal of the CMDLINER_LEGACY_PREFIXES workaround in 3.0.0 so we're simply thinking ahead.

Well that change will not happen before years at which point I would have expected and/or made sure that you would have migrated to the new experience.

On a more personal note, i personally think this change is quite user-hostile and this lost my trust to any future change that you might make in cmdliner. I personally think cmdliner 2.0.0 should've been a separate new cmdliner2 library or something like that.

It's difficult to satisfy everyone but there are very reasonable points that can be made against the feature and from an hci point of view it's much better to have a consistent experience across your cli tools. But I understand programmers rarely understand these hci issues.

I'm sorry to have lost your trust (also please note that you were the only one who expressed disagreement with the change). But I can say that with this move you lost mine. To me this looks like favouring your preference and experience of the tool over providing a great experience to end-users.

But if you prefer I can flood you with them.

Please do, it's great to know in any case

Well I will say that given what is happening here, I'm not really in the mood of helping improve opam. I will rather treat opam as something I have to cope with.

The module name is renamed to OpamCmdliner to allow end-users of the opam libraries to use upstream cmdliner
@kit-ty-kate kit-ty-kate merged commit 8521e32 into ocaml:master Nov 7, 2025
58 checks passed
@kit-ty-kate kit-ty-kate deleted the vendor-cmdliner branch November 7, 2025 19:00
This was referenced Nov 7, 2025
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.

cmdliner 2.0.0 support

3 participants