mirage / ocaml-cohttp

An OCaml library for HTTP clients and servers using Lwt or Async
Other
713 stars 174 forks source link

Fails to build: Multiple definition of the module name Fields #573

Closed thedufer closed 7 years ago

thedufer commented 7 years ago

Building via either OPAM or git clone/jbuilder build results in a strange error:

File "cohttp/src/link.ml", line 123, characters 10-11:
Error: Multiple definition of the module name Fields.
       Names must be unique in a given structure or signature.

It points to the definition of the type 'a Ext.t; presumably the error is coming from [@@deriving fields], but I don't see any other definition of a Fields module in that scope.

This is on OS El Capitan, with the 4.03.0 compiler. ppx_fields_conv is at v0.9.0.

avsm commented 7 years ago

What's your full opam list?

thedufer commented 7 years ago

This first showed up at the end of an opam upgrade, so I think they're pretty up-to-date.

# Installed packages for system:
alcotest                        0.8.0  Logo](https://raw.githubusercontent.com/m
angstrom                        0.6.0  Parser combinators built for speed and me
asn1-combinators                0.1.3  Define ASN.1 grammars in OCaml
astring                         0.8.3  Alternative String module for OCaml
async                          v0.9.0  Monadic concurrency library
async_extra                    v0.9.0  Monadic concurrency library
async_kernel                   v0.9.0  Monadic concurrency library
async_rpc_kernel               v0.9.0  Platform-independent core of Async RPC li
async_unix                     v0.9.0  Monadic concurrency library
base                           v0.9.3  Full standard library replacement for OCa
base-bigarray                    base  Bigarray library distributed with the OCa
base-bytes                       base  Bytes library distributed with the OCaml 
base-num                         base  Num library distributed with the OCaml co
base-threads                     base  Threads library distributed with the OCam
base-unix                        base  Unix library distributed with the OCaml c
base64                          2.2.0  Base64 encoding for OCaml
bin_prot                       v0.9.1  A binary protocol generator
biniou                          1.2.0  Binary data format designed for speed, sa
calendar                       2.03.2  Library for handling dates and times in y
camlp4                    4.03+system  Camlp4 is a system for writing extensible
camomile                        0.8.5  A comprehensive Unicode library
cmdliner                        1.0.0  Declarative definition of command line in
conduit                         1.0.0  Network conduit library
conduit-async                   1.0.0  Network conduit library
conduit-lwt                     1.0.0  Network conduit library
conduit-lwt-unix                1.0.0  Network conduit library
conf-autoconf                     0.1  Virtual package relying on autoconf insta
conf-gmp                            1  Virtual package relying on a GMP lib syst
conf-m4                             1  Virtual package relying on m4
conf-perl                           1  Virtual package relying on perl
conf-pkg-config                   1.0  Virtual package relying on pkg-config ins
conf-which                          1  Virtual package relying on which
configurator                   v0.9.1  Helper library for gathering system confi
core                           v0.9.1  Industrial strength alternative to OCaml'
core_kernel                    v0.9.0  Industrial strength alternative to OCaml'
cppo                            1.5.0  Equivalent of the C preprocessor for OCam
cpuid                           0.1.1  Detect CPU features
cstruct                         3.1.1  Access C-like structures directly from OC
cstruct-lwt                     3.1.1  Access C-like structures directly from OC
ctypes                         0.12.1  Combinators for binding to C libraries wi
ctypes-foreign                  0.4.0  Virtual package for enabling the ctypes.f
curses                          1.0.3  Bindings to curses/ncurses
depext                          1.0.5  Query and install external dependencies o
dispatch                        0.4.0  Path-based dispatching for client- and se
dns                             1.0.0  DNS client and server implementation in p
dns-lwt                         1.0.0  DNS client and server implementation in p
duration                        0.1.0  Conversions to various time units
easy-format                     1.2.0  High-level and functional interface to th
faraday                         0.3.0  A library for writing fast and memory-eff
fieldslib                      v0.9.0  Syntax extension to define first class va
fmt                             0.8.4  OCaml Format pretty-printer combinators
hashcons                          1.2  OCaml hash-consing library
inotify                           2.1  Inotify bindings for ocaml.
integers                        0.2.2  Various signed and unsigned integer types
io-page                         2.0.0  Allocate memory pages suitable for aligne
ipaddr                          2.8.0  IP (and MAC) address manipulation
jane-street-headers            v0.9.0  Jane Street C header files
jbuilder                   1.0+beta11  Fast, portable and opinionated build syst
js_of_ocaml                       3.0  Compiler from OCaml bytecode to Javascrip
js_of_ocaml-compiler              3.0  Compiler from OCaml bytecode to Javascrip
js_of_ocaml-ppx                   3.0  Compiler from OCaml bytecode to Javascrip
jsonm                           1.0.1  Non-blocking streaming JSON codec for OCa
lablgl                           1.05  Interface to OpenGL
lambda-term                      1.11  Terminal manipulation library for OCaml
logs                            0.6.2  Logging infrastructure for OCaml
lwt                             3.1.0  Concurrency based on promises
lwt_react                       1.1.0  Helpers for using React with Lwt
magic-mime                      1.1.0  Map filenames to common MIME types
merlin                          3.0.1  Editor helper, provides completion, typin
mirage-block                    1.1.0  Utilities and module definitions for deal
mirage-block-lwt                1.1.0  Utilities and module definitions for deal
mirage-channel                  3.1.0  Buffered channels for MirageOS FLOW types
mirage-channel-lwt              3.1.0  Buffered channels for MirageOS FLOW types
mirage-clock                    1.3.0  Libraries and module types for portable c
mirage-clock-lwt                1.3.0  Libraries and module types for portable c
mirage-conduit                  3.0.1  Network conduit library
mirage-console                  2.3.5  Implementations of Mirage consoles, for U
mirage-console-lwt              2.3.5  Implementations of Mirage consoles, for U
mirage-device                   1.1.0  Foundational module types for devices.
mirage-dns                      3.0.0  DNS client and server implementation in p
mirage-flow                     1.3.0  Flow implementations and combinators for 
mirage-flow-lwt                 1.4.0  Flow implementations and combinators for 
mirage-fs                       1.1.1  MirageOS signatures for filesystem device
mirage-fs-lwt                   1.1.1  MirageOS signatures for filesystem device
mirage-kv                       1.1.1  MirageOS signatures for key/value devices
mirage-kv-lwt                   1.1.0  MirageOS utilities for interfacing with k
mirage-net                      1.1.1  Network signatures for MirageOS
mirage-net-lwt                  1.1.0  MirageOS TCP/IP networking library
mirage-no-solo5                     1  Virtual package conflicting with mirage-s
mirage-no-xen                       1  Virtual package conflicting with mirage-x
mirage-profile                  0.8.1  collect runtime profiling information in 
mirage-protocols                1.2.0  MirageOS signatures for network protocols
mirage-protocols-lwt            1.2.0  MirageOS signatures for network protocols
mirage-random                   1.1.0  Random signatures for MirageOS, and an im
mirage-stack                    1.1.0  MirageOS signatures for network stacks
mirage-stack-lwt                1.1.0  MirageOS signatures for network stacks
mirage-time                     1.1.0  Time operations for MirageOS
mirage-time-lwt                 1.1.0  Time operations for MirageOS
mirage-types                    3.0.0  Module type definitions for Mirage-compat
mirage-types-lwt                3.0.0  Lwt module type definitions for Mirage-co
namespaces                      0.5.1  Turn directories into OCaml modules
nocrypto                        0.5.4  Simpler crypto
num                                 0  The Num library for arbitrary-precision i
oasis                          0.4.10  Tooling for building OCaml libraries and 
ocaml-compiler-libs            v0.9.0  OCaml compiler libraries repackaged
ocaml-migrate-parsetree         1.0.1  Convert OCaml parsetrees between differen
ocamlbuild                     0.11.0  OCamlbuild is a build system with builtin
ocamlfind                       1.7.3  A library manager for OCaml
ocamlify                        0.0.1  Include files in OCaml code
ocamlmod                        0.0.8  Generate OCaml modules from source files
ocb-stubblr                     0.1.1  OCamlbuild plugin for C stubs
ocp-build                1.99.18-beta  Project manager for OCaml
ocp-indent                      1.6.0  A simple tool to indent OCaml programs
ocplib-endian                     1.0  Optimised functions to read and write int
octavius                        1.1.0  Ocamldoc comment syntax parser
ounit                           2.0.0  Unit testing framework loosely based on H
postgresql                      4.0.1  postgresql-ocaml - bindings to the Postgr
ppx_assert                     v0.9.0  Assert-like extension nodes that raise us
ppx_ast                        v0.9.1  OCaml AST used by Jane Street ppx rewrite
ppx_base                       v0.9.0  Base set of ppx rewriters
ppx_bench                      v0.9.1  Syntax extension for writing in-line benc
ppx_bin_prot                   v0.9.0  Generation of bin_prot readers and writer
ppx_compare                    v0.9.0  Generation of comparison functions from t
ppx_core                       v0.9.0  Standard library for ppx rewriters
ppx_cstruct                     3.1.1  Access C-like structures directly from OC
ppx_custom_printf              v0.9.0  Printf-style format-strings for user-defi
ppx_derivers                      1.0  Shared [@@deriving] plugin registry
ppx_deriving                  4.1+dev  Type-driven code generation for OCaml >=4
ppx_driver                     v0.9.1  Feature-full driver for OCaml AST transfo
ppx_enumerate                  v0.9.0  Generate a list containing all values of 
ppx_expect                     v0.9.0  Cram like framework for OCaml
ppx_fail                       v0.9.0  Add location to calls to failwiths
ppx_fields_conv                v0.9.0  Generation of accessor and iteration func
ppx_hash                       v0.9.0  A ppx rewriter that generates hash functi
ppx_here                       v0.9.1  Expands [%here] into its location
ppx_inline_test                v0.9.2  Syntax extension for writing in-line test
ppx_jane                       v0.9.0  Standard Jane Street ppx rewriters
ppx_js_style                   v0.9.0  Code style checker for Jane Street Packag
ppx_let                        v0.9.0  Monadic let-bindings
ppx_metaquot                   v0.9.0  Write OCaml AST fragment using OCaml synt
ppx_optcomp                    v0.9.0  Optional compilation for OCaml
ppx_optional                   v0.9.0  Pattern matching on flat options
ppx_pipebang                   v0.9.0  A ppx rewriter that inlines reverse appli
ppx_sexp_conv                  v0.9.0  Generation of S-expression conversion fun
ppx_sexp_message               v0.9.0  A ppx rewriter for easy construction of s
ppx_sexp_value                 v0.9.0  A ppx rewriter that simplifies building s
ppx_tools                  5.0+4.03.0  Tools for authors of ppx rewriters and ot
ppx_tools_versioned             5.0.1  A variant of ppx_tools based on ocaml-mig
ppx_traverse                   v0.9.0  Automatic generation of open-recursion cl
ppx_traverse_builtins          v0.9.0  Builtins for Ppx_traverse
ppx_type_conv                  v0.9.0  Support Library for type-driven code gene
ppx_typerep_conv               v0.9.0  Generation of runtime types from type dec
ppx_variants_conv              v0.9.0  Generation of accessor and iteration func
ptime                           0.8.3  POSIX time for OCaml
re                              1.7.1  RE is a regular expression library for OC
react                           1.2.1  Declarative events and signals for OCaml
result                            1.2  Compatibility Result module
sexplib                        v0.9.2  Library for serializing OCaml values to a
spawn                          v0.9.0  Spawning sub-processes
stdio                          v0.9.0  Standard IO library for OCaml
stringext                       1.4.3  Extra string functions for OCaml
tgls                            0.8.5  Thin bindings to OpenGL {3,4} and OpenGL 
tls                             0.8.0  Transport Layer Security purely in OCaml
topkg                           0.9.0  The transitory OCaml software packager
typerep                        v0.9.0  typerep is a library for runtime types.
typerex-build            1.99.17-beta  Project manager for OCaml
uchar                           0.0.2  Compatibility library for OCaml's Uchar m
uri                             1.9.4  RFC3986 URI/URL parsing library
utop                            2.0.1  Universal toplevel for OCaml
uutf                            1.0.1  Non-blocking streaming Unicode codec for 
variantslib                    v0.9.0  Part of Jane Street's Core library
vchan                           3.0.0  Xen Vchan implementation
x509                            0.5.3  X.509 certificate (RFC5280) library
xenstore                        1.4.0  Xenstore protocol clients and server
xenstore_transport              0.9.6  Low-level libraries for connecting to a x
yojson                          1.4.0  Yojson is an optimized parsing and printi
zarith                            1.5  Implements arithmetic and logical operati
zed                               1.5  Abstract engine for text edition in OCaml
rgrinberg commented 7 years ago

What about any pins?

$ opam pin
thedufer commented 7 years ago

No pins as of now. My first attempt to fix this involved clearing all of them.

agarwal commented 7 years ago

I'm getting the same problem after an opam update && opam upgrade. I tried pinning back down to 0.22.0, but getting the same problem even with the older version now, though in a different file in that case:

# File "lib/cookie.mli", line 38, characters 7-8:
# Error: Multiple definition of the module name Fields.
#        Names must be unique in a given structure or signature.
rgrinberg commented 7 years ago

@agarwal are you using 4.03.0 as well?

agarwal commented 7 years ago

@agarwal are you using 4.03.0 as well?

Yes.

rgrinberg commented 7 years ago

Do you think you can reproduce this error without cohttp on 4.03?, just with ppx_sexp_conv and jbuilder

agarwal commented 7 years ago

Not sure I understand. The error is in compilation of cohttp, so do you have reason to believe the error would occur with another package like ppx_sexp_conv? You might be right. I just managed to compile cohttp fine, but then I installed ppx_deriving_yojson which triggered a recompilation of cohttp and it again failed.

agarwal commented 7 years ago

I created a fresh 4.03.0 opam switch and then did opam install jbuilder ppx_sexp_conv. No errors.

agarwal commented 7 years ago

It appears to be a conflict with ppx_deriving 4.2. Here's my test:

$ opam remove ppx_deriving cohttp
$ opam install ppx_deriving.4.1 cohttp
(* No errors *)

$ opam remove ppx_deriving cohttp
$ opam install ppx_deriving.4.2 cohttp
...
# File "cohttp/src/link.ml", line 123, characters 10-11:
# Error: Multiple definition of the module name Fields.
#        Names must be unique in a given structure or signature.

For those stuck, a workaround is thus to do opam pin add ppx_deriving 4.1.

thedufer commented 7 years ago

I bumped to 4.04 and am having no problems there. Having looked at the code it points to it seems pretty clear that this is an issue with the preprocessor and/or build system rather than cohttp.

agarwal commented 7 years ago

Does anyone know the correct repo to report this issue to? I'm not sure ppx_deriving is at fault either.

agarwal commented 7 years ago

In cohttp's opam package, it would be good to provide the constraint ppx_deriving < 4.2 when ocaml = 4.03.0 or something similar.

rgrinberg commented 7 years ago

I think that constraint should be added to ppx_fields_conv itself. I doubt thus is cohttp specific

On Fri, Aug 25, 2017, 9:08 AM Ashish Agarwal notifications@github.com wrote:

In cohttp's opam package, it would be good to provide the constraint ppx_deriving < 4.2 when ocaml = 4.03.0 or something similar.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mirage/ocaml-cohttp/issues/573#issuecomment-324914975, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIe-yuBYeekhS_aIiAG2fscD5WKItE8ks5sbsdggaJpZM4OpNmj .

samoht commented 7 years ago

It's an issue with ppx_deriving not ppx_fields_conv: if you look at the generated .pp.ml (using ocamlc -dsource _build/default/cohttp/src/link.pp.ml you will see that all the generated code is duplicated (even for type only using with [@@deriving sexp]). I have just merged a PR in opam-repository to not install ppx_deriving.4.2 on 4.03.

samoht commented 7 years ago

Also there is now https://github.com/ocaml-ppx/ppx_deriving/issues/147

rgrinberg commented 7 years ago

Thomas Gazagnaire notifications@github.com writes:

It's an issue with ppx_deriving not ppx_fields_conv: if you look at the generated .pp.ml (using ocamlc -dsource _build/default/cohttp/src/link.pp.ml you will see that all the generated code is duplicated (even for type using with [@@deriving sexp]). I have just merged a PR in opam-repository to not install ppx_deriving on 4.03.

Thanks for the investigation Thomas.

This all makes sense. Especially the fact that only ppx_fields_conv is causing compilation errors. Since for other converters, the functions just end up being shadowed.

agarwal commented 7 years ago

This issue can be closed. The real problem is reported at ocaml-ppx/ppx_deriving#147.