issuu / ocaml-protoc-plugin

ocaml-protoc-plugin

Home Page:https://issuu.github.io/ocaml-protoc-plugin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mac M1 installation requires a new release

patzm opened this issue Β· comments

Preface: I found the solution / problem while describing the issue 🀦. In a nutshell: please make a release so that I can benefit from the fix that you already have in master. Please close the issue when the release is done.

Nonetheless, I will keep the issue description below for others to find it while searching the 🌐.

Problem description

I try installing this package on an M1 mac. One of the key differences here is that homebrew does not install itself in /usr/local and hence doesn't link all things to previously well known places. I get the following failure during installation:

❯ opam install ocaml-protoc-plugin
The following actions will be performed:
  βˆ— install ocaml-protoc-plugin 4.2.0

<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
⬇ retrieved ocaml-protoc-plugin.4.2.0  (https://opam.ocaml.org/cache)
[ERROR] The compilation of ocaml-protoc-plugin.4.2.0 failed at "dune build -p ocaml-protoc-plugin -j 7".

#=== ERROR while compiling ocaml-protoc-plugin.4.2.0 ==========================#
# context     2.1.2 | macos/arm64 | ocaml.4.14.0 | https://opam.ocaml.org#4d2fbd56
# path        ~/.opam/default/.opam-switch/build/ocaml-protoc-plugin.4.2.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p ocaml-protoc-plugin -j 7
# exit-code   1
# env-file    ~/.opam/log/ocaml-protoc-plugin-80671-87983c.env
# output-file ~/.opam/log/ocaml-protoc-plugin-80671-87983c.out
### output ###
# File "src/google_types/dune", line 12, characters 0-1057:
# 12 | (rule
# 13 |  (targets any.ml api.ml descriptor.ml duration.ml empty.ml field_mask.ml
# 14 |           source_context.ml struct.ml timestamp.ml type.ml wrappers.ml)
# ....30 |        %{read-lines:google_include}/google/protobuf/type.proto
# 31 |        %{read-lines:google_include}/google/protobuf/wrappers.proto
# 32 | )))
# (cd _build/default/src/google_types && /opt/homebrew/bin/protoc -I /usr/local/include --plugin=protoc-gen-ocaml=../plugin/protoc_gen_ocaml.exe --ocaml_out=. /usr/local/include/google/protobuf/any.proto /usr/local/include/google/protobuf/api.proto /usr/local/include/google/protobuf/descriptor.proto /usr/local/include/google/protobuf/duration.proto /usr/local/include/google/protobuf/empty.proto[...]
# /usr/local/include: warning: directory does not exist.
# Could not make proto path relative: /usr/local/include/google/protobuf/any.proto: No such file or directory



<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
β”Œβ”€ The following actions failed
β”‚ Ξ» build ocaml-protoc-plugin 4.2.0
└─
╢─ No changes have been performed

Essentially, it tries to find the .proto headers (like any.proto) in /usr/local/include/google/protobuf/. However, on my system they are installed to for instance /opt/homebrew/Cellar/protobuf/3.19.4/include/google/protobuf and then linked to /opt/homebrew/include/google/protobuf. FYI: calling brew --prefix yields /opt/homebrew. Also, calling

$ pkg-config protobuf --variable=includedir
/opt/homebrew/Cellar/protobuf/3.19.4/include

Seeing this line

(system "pkg-config protobuf --variable=includedir"))))

would make me guess that the installation routine should have found it πŸ€”.

Ok, the latest release from 16th of May 2022 is v4.2.0 which still has the following code:

(rule
(targets google_include)
(action (with-stdout-to %{targets} (system "[ -d /usr/include/google/protobuf ] && echo /usr/include || echo /usr/local/include" ))))

Hence, it doesn't ask pkg-config for the correct include path. Problem solved βœ…

Actually, the fix is already pretty old: 724756f. From 15 months ago 😱.

I will create a new release by the end of the week, which will contain the fix.