Hello, I’ve been trying to follow the installation instructions at Installing OCaml · OCaml Documentation using MinGW through MSYS2, and almost everything compiles except topkg and ocp-indent. the log when I try to install topkg and ocp-indent through opam reads
The ocp-indent error is strange. The last lines of the output relate to a warning that is explicitly declared as not an error, so it shouldn’t have prevented the build from succeeding. It might be helpful to show the whole contents of output-file, as maybe the actual error can be found there.
Here’s the log, the actual error appears to be the same as the error for topkg
File “src/ocp-indent-dynlink/dune”, line 5, characters 12-19:
5 | (libraries findlib dynlink ocp-indent.lexer ocp-indent.utils))
^^^^^^^
Error: Library “findlib” not found.
→ required by library “ocp-indent.dynlink” in
_build/default/src/ocp-indent-dynlink
→ required by executable indentMain in src/ocp-indent/dune:9
→ required by _build/default/src/ocp-indent/indentMain.exe
→ required by _build/install/default/bin/ocp-indent.exe
→ required by _build/default/ocp-indent.install
→ required by alias install
(cd build/default && C:\Users\willf\AppData\Local\opam\default\bin\ocamlc.opt.exe -w -40 -w -9 -warn-error -57 -g -bin-annot -I src/ocp-indent-lib/.ocp_indent_lib.objs/byte -I src/ocp-indent-lexer/.ocp_indent_lexer.objs/byte -I src/ocp-indent-utils/.ocp_indent_utils.objs/byte -intf-suffix .ml -no-alias-deps -o src/ocp-indent-lib/.ocp_indent_lib.objs/byte/indentBlock.cmo -c -impl src/ocp-indent-lib/indentBlock.ml)
File “src/ocp-indent-lib/indentBlock.ml”, lines 1698-1700, characters 4-13:
1698 | …{kind=KExpr i}::p,
1699 | ({token=EOF} :: tok :: _ (* spurious warning 57 here *)
1700 | | tok::)
Warning 57 [ambiguous-var-in-pattern-guard]: Ambiguous or-pattern variables under guard;
variable tok appears in different places in different or-pattern alternatives.
Only the first match will be used to evaluate the guard expression.
(See manual section 11.5)
(cd build/default && C:\Users\willf\AppData\Local\opam\default\bin\ocamlopt.opt.exe -w -40 -w -9 -warn-error -57 -g -I src/ocp-indent-lib/.ocp_indent_lib.objs/byte -I src/ocp-indent-lib/.ocp_indent_lib.objs/native -I src/ocp-indent-lexer/.ocp_indent_lexer.objs/byte -I src/ocp-indent-lexer/.ocp_indent_lexer.objs/native -I src/ocp-indent-utils/.ocp_indent_utils.objs/byte -I src/ocp-indent-utils/.ocp_indent_utils.objs/native -intf-suffix .ml -no-alias-deps -o src/ocp-indent-lib/.ocp_indent_lib.objs/native/indentBlock.cmx -c -impl src/ocp-indent-lib/indentBlock.ml)
File “src/ocp-indent-lib/indentBlock.ml”, lines 1698-1700, characters 4-13:
1698 | …{kind=KExpr i}::p,
1699 | ({token=EOF} :: tok :: _ (* spurious warning 57 here *)
1700 | | tok::)
Warning 57 [ambiguous-var-in-pattern-guard]: Ambiguous or-pattern variables under guard;
variable tok appears in different places in different or-pattern alternatives.
Only the first match will be used to evaluate the guard expression.
(See manual section 11.5)
I should have more closely noticed the OCaml version (4.14.2) and the opam-repository sha (ee3428377 - so including ocaml/opam-repository#28897)! I’m struggling to reproduce this - what’s the output from opam list and opam pin at the moment in your switch?
PS C:\\Users\\willf> opam list
# Packages matching: installed
# Name # Installed # Synopsis
arch-x86_64 1 Build OCaml for amd64 (64-bit)
base v0.16.4 Full standard library replacement for OCaml
base-bigarray base
base-bytes base Bytes library distributed with the OCaml compiler
base-threads base
base-unix base
camlp-streams 5.0.1 The Stream and Genlex libraries for use with Camlp4 and Camlp5
chrome-trace 3.20.2 Chrome trace event generation library
cmdliner 2.0.0 Declarative definition of command line interfaces for OCaml
conf-mingw-w64-gcc-x86_64 1 Virtual package for GCC on x86_64 mingw-w64 (64-bit x86_64)
cppo 1.8.0 Code preprocessor like cpp for OCaml
csexp 1.5.2 Parsing and printing of S-expressions in Canonical form
dune 3.20.2 Fast, portable, and opinionated build system
dune-build-info 3.20.2 Embed build information inside executable
dune-configurator 3.20.2 Helper library for gathering system configuration
dune-rpc 3.20.2 Communicate with dune using rpc
dyn 3.20.2 Dynamic type
either 1.0.0 Compatibility Either module
fiber 3.7.0 Dune’s monadic structured concurrency library
fix 20250919 Algorithmic building blocks for memoization, recursion, and more
flexdll 0.44 FlexDLL Sources
host-arch-x86_64 1 OCaml on amd64 (64-bit)
host-system-mingw 1 OCaml for mingw-w64
jsonrpc 1.21.0-4.14 Jsonrpc protocol implemenation
lwt 5.9.2 Promises and event-driven I/O
menhir 20250912 An LR(1) parser generator
menhirCST 20250912 Runtime support library for unparsers generated by Menhir
menhirLib 20250912 Runtime support library for parsers generated by Menhir
menhirSdk 20250912 Compile-time library for auxiliary tools related to Menhir
merlin-lib 4.19-414 Merlin’s libraries
mew 0.1.0 Modal editing witch
msvs-detect 0.7.0 Microsoft Visual Studio environment settings detection script
msys2 0.1.0 MSYS2 Environment Settings
msys2-mingw64 1 MSYS2 MINGW64 Environment
ocaml 4.14.2 The OCaml compiler (virtual package)
ocaml-config 3 OCaml Switch Configuration
ocaml-env-mingw64 1 GCC mingw-w64 OCaml Runtime Dependency (64-bit)
ocaml-options-vanilla 1 Ensure that OCaml is compiled with no special options enabled
ocaml-variants 4.14.2+options Official release of OCaml 4.14.2
ocaml-version 4.0.3 Manipulate, parse and generate OCaml compiler version strings
ocamlbuild 0.16.1 OCamlbuild is a build system with builtin rules to easily build most OCaml proj
ocamlc-loc 3.20.2 Parse ocaml compiler output into structured form
ocamlfind 1.9.8.git pinned to version 1.9.8.git at git+https://github.com/dra27/ocamlfind.git#win-f
ocamlformat-rpc-lib 0.28.1 Auto-formatter for OCaml code (RPC mode)
ocamlgraph 2.2.0 A generic graph library for OCaml
ocplib-endian 1.2 Optimised functions to read and write int16/32/64 from strings and bigarrays
opam-core 2.1.6 Core library for opam 2.1
opam-file-format 2.2.0 Parser and printer for the opam file syntax
opam-format 2.1.6 Format library for opam 2.1
ordering 3.20.2 Element ordering
pp 2.0.0 Pretty-printing library
ppx_yojson_conv_lib v0.16.0 Runtime lib for ppx_yojson_conv
re 1.14.0 RE is a regular expression library for OCaml
result 1.5 Compatibility Result module
seq base Compatibility package for OCaml’s standard iterator type starting from 4.07.
sexplib0 v0.16.0 Library containing the definition of S-expressions and some base converters
spawn v0.17.0 Spawning sub-processes
stdio v0.16.0 Standard IO library for OCaml
stdune 3.20.2 Dune’s unstable standard library
system-mingw 1 Build OCaml for mingw-w64
trie 1.0.0 Strict impure trie tree
uchar 0.0.2 Compatibility library for OCaml’s Uchar module
winpthreads 20240209-1 Posix Threads for Windows (winpthreads) Sources
xdg 3.20.2 XDG Base Directory Specification
yojson 2.2.2 Yojson is an optimized parsing and printing library for the JSON format
I’m very puzzled as to what the full series of steps is/was here. What’s additionally the output of opam option sys-pkg-manager-cmd and, if you don’t mind sharing it, what’s your PATH? (echo %PATH%).
What made you install MSYS2, though, or did you not knowingly do that?
Right, got it: if you still have my win-fixes branch pinned, opam upgrade ocamlfind should fix it (it will pull an updated part). As it happens, downgrading to ocamlfind 1.9.5 should also work.
All that said, the fundamental problem is that your shell is misconfigured.
Did you put C:\msys64\usr\bin etc. into PATH yourself, or did an installer do it? It needs to appear beforeC:\WINDOWS\system32 (if you didn’t configure this yourself and it was done by an installer, that’d be useful to know, because opam should mitigate this, but I wasn’t aware that any of the MSYS2 installers ever set-up PATH in this way).
The background, as it happens, is one of the “improvements” in https://github.com/ocaml/ocamlfind/pull/73 introduced a dependency on find, and because you’ve got MSYS2’s C:\msys64\usr\binafterC:\WINDOWS\system32 the script is trying to use the Windowsfind command, which doesn’t work - this specifically causes ocamlfind’s configure script not to generate the META file for the findlib package (that’s it’s own library) which means that the topfind script doesn’t work, and all the other failures stem from that.