Skip to content

conf-perl.3, conf-perl-{string-shellquote,ipc-system-simple}.4: Cygwin/MSYS2 support#29613

Open
smorimoto wants to merge 3 commits intomasterfrom
conf-perl-cygwin-cpan
Open

conf-perl.3, conf-perl-{string-shellquote,ipc-system-simple}.4: Cygwin/MSYS2 support#29613
smorimoto wants to merge 3 commits intomasterfrom
conf-perl-cygwin-cpan

Conversation

@smorimoto
Copy link
Copy Markdown
Member

@smorimoto smorimoto commented Mar 29, 2026

Summary

Add Cygwin and MSYS2 support for conf-perl-* packages. These Perl modules have no corresponding system packages in either Cygwin or MSYS2 package repositories, so depexts alone cannot satisfy the dependency.

Changes

conf-perl.3 (new version):

  • Creates a self-contained CPAN configuration (MyConfig.pm) inside the opam switch, avoiding conflicts with any existing user CPAN configuration
  • Uses %{prefix}% to locate the switch directory and normalizes backslashes to forward slashes for Windows compatibility (opam → Cygwin command-line → Perl requires triple-layer escaping)
  • Exports perl5lib and cpan_config_dir via .config file so dependent packages can find installed modules and use the switch-local CPAN config
  • Sets SHELL, PERL_MM_USE_DEFAULT, and PERL5LIB via setenv for dependent packages
  • On MSYS2, the MyConfig.pm sets make to /usr/bin/make to avoid the mingw make (/mingw64/bin/make.EXE) which cannot handle POSIX paths
  • On MSYS2, adds perl-devel to depexts (provides Config.pm required by ExtUtils::MakeMaker)

conf-perl-{string-shellquote,ipc-system-simple}.4 (new versions):

  • Depend on conf-perl >= 3
  • On Cygwin/MSYS2, install the required Perl module via perl -I <cpan_config_dir> -MCPAN using the switch-local CPAN configuration
  • SHELL, PERL_MM_USE_DEFAULT, and PERL5LIB are propagated from conf-perl via setenv
  • Verify the module is available via perl -MModule -e 1

Background

Since setup-ocaml v3.5.0, opam uses --cygwin-internal-install which manages its own internal Cygwin. This means opam uses the internal Cygwin perl for conf-perl-* verification. The corresponding Cygwin/MSYS2 system packages for these Perl modules (perl-String-ShellQuote, etc.) do not exist in the Cygwin or MSYS2 package repositories, so depexts cannot resolve them.

The fix installs modules via the CPAN client bundled with perl, with platform-specific handling:

  • Cygwin: SHELL=/bin/sh must be set to work around a fileparse() crash in CPAN::FirstTime (RT #131313)
  • MSYS2: Additionally requires a custom MyConfig.pm that points make to /usr/bin/make (the MSYS2 POSIX make), because opam's PATH ordering places /mingw64/bin/make.EXE (mingw make) first, which cannot handle POSIX paths

Windows path handling

On Windows, %{prefix}% returns a path with backslashes (e.g. D:\a\opam-repository\opam-repository\_opam). Since opam's .config file parser treats \ as an escape character, the generated conf-perl.config must use forward slashes. The Perl script normalizes backslashes via s{\\}{/}g, but this requires 8 backslashes (\\\\\\\\) in the opam file to survive three escaping layers: opam string unescaping, Cygwin command-line processing, and Perl regex parsing.

Also requires setup-ocaml v3.6.0+ which installs the opam base packages (make, tar, unzip, rsync) on MSYS2 (ocaml/setup-ocaml#1096).

ref: ocaml/setup-ocaml#1094

@smorimoto smorimoto requested review from dra27 and kit-ty-kate March 29, 2026 11:16
@smorimoto smorimoto changed the base branch from master to use-setup-ocaml-for-windows-ci March 29, 2026 13:02
@smorimoto smorimoto force-pushed the conf-perl-cygwin-cpan branch from 3fa6ede to f325cd8 Compare March 29, 2026 13:06
@smorimoto smorimoto marked this pull request as draft March 29, 2026 13:24
@smorimoto smorimoto force-pushed the conf-perl-cygwin-cpan branch 2 times, most recently from 4b2b040 to f8d6c4d Compare March 29, 2026 14:01
@smorimoto smorimoto force-pushed the use-setup-ocaml-for-windows-ci branch from 4a376cb to 95bf960 Compare March 29, 2026 14:12
Base automatically changed from use-setup-ocaml-for-windows-ci to master March 29, 2026 14:15
@smorimoto smorimoto force-pushed the conf-perl-cygwin-cpan branch from f8d6c4d to 792c360 Compare March 29, 2026 14:42
@smorimoto smorimoto force-pushed the conf-perl-cygwin-cpan branch 6 times, most recently from c0b87bc to aea3885 Compare March 29, 2026 16:29
@kit-ty-kate kit-ty-kate removed their request for review March 29, 2026 16:44
@smorimoto smorimoto force-pushed the conf-perl-cygwin-cpan branch 11 times, most recently from 3f352ec to df6af1e Compare March 30, 2026 03:53
@smorimoto smorimoto force-pushed the conf-perl-cygwin-cpan branch 3 times, most recently from 13c0b16 to 62ce604 Compare March 30, 2026 05:02
@smorimoto smorimoto changed the title conf-perl-{string-shellquote,ipc-system-simple}.4: use cpan on Cygwin conf-perl.3, conf-perl-{string-shellquote,ipc-system-simple}.4: Cygwin/MSYS2 support Mar 30, 2026
@a2line
Copy link
Copy Markdown
Contributor

a2line commented Mar 30, 2026

Hello smorimoto,

I’ve successfully tested your branch on our Windows CI by replacing the Perl module installation step with:

opam repo add conf-perl-fix https://github.com/ocaml/opam-repository.git#conf-perl-cygwin-cpan --all --rank=1

conf-perl.3, conf-perl-ipc-system-simple.4, and conf-perl-string-shellquote.4 resolved and installed transparently — no manual steps required. The modules are picked up automatically during opam install . --deps-only, just like on Unix.

This is exactly what we needed. It makes maintaining manual workarounds for conf-perl on Windows CI completely obsolete.

Thank you for the thorough work and the quick turnaround, especially over the weekend!

a2line added a commit to a2line/geneweb that referenced this pull request Mar 30, 2026
conf-perl-ipc-system-simple.4 and conf-perl-string-shellquote.4
(ocaml/opam-repository#29613) add native Cygwin/MSYS2 support,
installing Perl modules via cpan automatically during opam
dependency resolution — no manual step needed anymore.

This removes the curl+cpanm and opam pin workaround introduced
after setup-ocaml v3.5.0 broke conf-perl resolution on Windows
by switching to --cygwin-internal-install (ocaml/setup-ocaml#1067).
a2line added a commit to a2line/geneweb that referenced this pull request Mar 30, 2026
conf-perl-ipc-system-simple.4 and conf-perl-string-shellquote.4
(ocaml/opam-repository#29613) add native Cygwin/MSYS2 support,
installing Perl modules via cpan automatically during opam
dependency resolution — no manual step needed anymore.

This removes the curl+cpanm and opam pin workaround introduced
after setup-ocaml v3.5.0 broke conf-perl resolution on Windows
by switching to --cygwin-internal-install (ocaml/setup-ocaml#1067).
@smorimoto smorimoto force-pushed the conf-perl-cygwin-cpan branch 2 times, most recently from 71ace13 to da071f3 Compare March 30, 2026 08:33
@smorimoto smorimoto marked this pull request as ready for review April 4, 2026 05:21
…shellquote.4

Add new versions of conf-perl packages with Cygwin CPAN support for
installing Perl modules on Windows.
On Windows (Cygwin/MSYS2), %{prefix}% returns a path with
backslashes (e.g. D:\a\...), which causes "illegal escape sequence"
errors when opam parses the generated conf-perl.config file.
Normalize backslashes to forward slashes before writing paths.
opam -> Cygwin shell -> Perl has three escaping layers:
- opam string: \\\\\\\\ -> \\\\
- Cygwin command-line: \\\\ -> \\
- Perl regex: \\ -> matches literal \
@smorimoto smorimoto force-pushed the conf-perl-cygwin-cpan branch from 918c45a to 5f64e54 Compare April 4, 2026 05:22
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.

v3.5.0 breaks conf-perl-* package resolution on Windows

2 participants