ocaml-lsp
ocaml-lsp copied to clipboard
Build instructions are inacurate
Running the following:
$ git clone --recurse-submodules http://github.com/ocaml/ocaml-lsp.git
$ cd ocaml-lsp
$ make build
With a 4.10.0 opam switch that only contains dune
yields the following:
$ make build
dune build
File "lsp/src/dune", line 6, characters 40-59:
6 | (libraries stdune yojson threads.posix ppx_yojson_conv_lib fiber uutf)
^^^^^^^^^^^^^^^^^^^
Error: Library "ppx_yojson_conv_lib" not found.
Hint: try: dune external-lib-deps --missing @@default
File "vendor/stdune/dune", line 4, characters 16-25:
4 | (action (run %{bin:cppo} -V OCAML:%{ocaml_version} %{ml} -o %{targets})))
^^^^^^^^^
Error: Program cppo not found in the tree or in PATH
(context: default)
File "vendor/stdune/dune", line 11, characters 12-24:
11 | (libraries stdlib-shims unix dune_csexp)
^^^^^^^^^^^^
Error: Library "stdlib-shims" not found.
Hint: try: dune external-lib-deps --missing @@default
Error: Program menhir not found in the tree or in PATH
(context: default)
Hint: try: opam install menhir
File "ocaml-lsp-server/src/dune", line 9, characters 18-33:
9 | cmdliner fiber dune-build-info))
^^^^^^^^^^^^^^^
Error: Library "dune-build-info" not found.
Hint: try: dune external-lib-deps --missing @@default
make: *** [build] Error 1
Could you try this instead
That does appear to work! Thanks! There are a few issues that I'm running into though:
-
The readme claims that
This project uses submodules to handle dependencies. This is done so that users who install ocaml-lsp-server into their sandbox will not share constraints on the same dependencies that ocaml-lsp-server is using."
but I think that making the switch defeats that purpose. Sadly, I'm inside a corporate environment where we already have our own compiler / stdlib / etc, and I think that the switch that was created here would cause issues.
-
I think that there's a missing
cd ocaml-lsp
in those steps -
make lsp-server
didn't appear to do anything. I needed to addcd ocaml-lsp-server/src && dune build @install
Here are the instructions that worked for me:
#!/bin/bash
set -euo pipefail
git clone --recurse-submodules [email protected]:ocaml/ocaml-lsp.git
opam switch create ./ ocaml-base-compiler.4.10.0
eval $(opam env)
opam install dune
export PATH="custom_ocaml_bin_dir_here:$PATH"
export CAML_LD_LIBRARY_PATH="custom_ocaml_lib_dir_here:$CAML_LD_LIBRARY_PATH"
cd ocaml-lsp
opam source stdlib-shims
opam source yojson
opam source ppx_yojson_conv_lib
opam source biniou
opam source dune-build-info
opam source alcotest
opam source cppo
opam source menhir
opam source easy-format
git clone --single-branch --branch duniverse-master https://github.com/dune-universe/lib-findlib.git
dune build ocaml-lsp-server/src/main.exe --release
file ./_build/default/ocaml-lsp-server/src/main.exe