ocaml-lsp icon indicating copy to clipboard operation
ocaml-lsp copied to clipboard

Build instructions are inacurate

Open TyOverby opened this issue 4 years ago • 3 comments

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

TyOverby avatar Jun 10 '20 01:06 TyOverby

Could you try this instead

image

smorimoto avatar Jun 10 '20 01:06 smorimoto

That does appear to work! Thanks! There are a few issues that I'm running into though:

  1. 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.

  2. I think that there's a missing cd ocaml-lsp in those steps

  3. make lsp-server didn't appear to do anything. I needed to add cd ocaml-lsp-server/src && dune build @install

TyOverby avatar Jun 10 '20 02:06 TyOverby

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

TyOverby avatar Jun 10 '20 15:06 TyOverby