Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dune developer preview: ocamllsp cannot read stdlib.cmi (corrupted compiled interface) #11229

Open
edwintorok opened this issue Dec 18, 2024 · 2 comments

Comments

@edwintorok
Copy link
Contributor

edwintorok commented Dec 18, 2024

Expected Behavior

ocamllsp works

Actual Behavior

ocamllsp fails.

Reproduction

  • PR with a reproducing test:
  1. Follow steps at https://preview.dune.build/ to install dune and a build a hello world project. This builds an OCaml 5.2.1.
  2. Run 'ocamllsp'. This downloads an ocamlformat and ocamllsp for 5.2.1, but it is a binary download for the musl toolchain (the one built by dune previously was using a GCC toolchain).
  3. Run an editor (e.g. Helix, or probably any other editor), and observe the error message.

Specifications

  • Version of dune (output of dune --version):
- "Dune Developer Preview: build 2024-12-18T09:09:58Z, git revision
3fc17eec135ab67a514c1cbb02182f7bccf6d042"
  • Version of ocaml (output of ocamlc --version)
    4.14.0
    (not relevant, because dune builds its own)

  • Operating system (distribution and version):

Additional information

I think this is because ocamllsp is a binary download built using the musl toolchain, and the hello world project uses a locally built OCaml compiler. Obviously interface hashes won't agree between the two, since it is a different compiler.

I assume ocamllsp would have to be built instead of downloaded as binary, since the musl version doesn't appear to be truly portable yet if it can only parse a musl based compiler.

ocamllsp
Locking dev-tools.locks/ocamlformat: Updating package repos "binary-packages", "                                                                                Locking dev-tools.locks/ocamlformat: Updating package repos "binary-packages", "                                                                                Locking dev-tools.locks/ocamlformat: Updating package repos "binary-packages", "                                                                                Locking dev-tools.locks/ocamlformat: Updating package repos "binary-packages", "                                                                                Locking dev-tools.locks/ocamlformat: Updating package repos "binary-packages", "                                                                                Locking dev-tools.locks/ocamlformat: Updating package repos "binary-packages", "                                                                                Locking dev-tools.locks/ocamlformat: Updating package repos "binary-packages", "                                                                                Locking dev-tools.locks/ocamlformat: Updating package repos "binary-packages", "                                                                                Locking dev-tools.locks/ocamlformat: Updating package repos "binary-packages", "                                                                                Solution for dev-tools.locks/ocamlformat:      
- ocamlformat.0.27.0+binary-ocaml-5.2.1-built-2024-12-04.0-x86_64-unknown-linux-musl
 Downloading ocamlformat.0.27.0+binary-ocaml-5.2.1-built-2024-12-04.0-x86_64-unknown-linux-musl
    Building ocamlformat.0.27.0+binary-ocaml-5.2.1-built-2024-12-04.0-x86_64-unknown-linux-musl
     Running 'ocamlformat --help'
Locking dev-tools.locks/ocaml-lsp-server: Updating package repos "binary-package                                                                                Locking dev-tools.locks/ocaml-lsp-server: Updating package repos "binary-package                                                                                Locking dev-tools.locks/ocaml-lsp-server: Updating package repos "binary-package                                                                                Locking dev-tools.locks/ocaml-lsp-server: Updating package repos "binary-package                                                                                Locking dev-tools.locks/ocaml-lsp-server: Updating package repos "binary-package                                                                                Locking dev-tools.locks/ocaml-lsp-server: Updating package repos "binary-package                                                                                Solution for dev-tools.locks/ocaml-lsp-server:      
- ocaml.5.2.1
- ocaml-base-compiler.5.2.1
- ocaml-config.3
- ocaml-lsp-server.1.20.1+binary-ocaml-5.2.1-built-2024-12-12.0-x86_64-unknown-linux-musl
 Downloading ocaml-lsp-server.1.20.1+binary-ocaml-5.2.1-built-2024-12-12.0-x86_64-unknown-linux-musl
    Building ocaml-lsp-server.1.20.1+binary-ocaml-5.2.1-built-2024-12-12.0-x86_64-unknown-linux-musl
     Running 'ocamllsp'     
dune pkg lock
Solution for dune.lock:                                              
- ocaml.5.2.1
- ocaml-base-compiler.5.2.1
- ocaml-config.3
⌛10s edwin ~/h/hello_world [default] ❯ dune exec "$PROJECT"
 Downloading ocaml-base-compiler.5.2.1
    Building ocaml-base-compiler.5.2.1
Hello, World!                      
  • Link to gist with verbose output (run dune with the --verbose flag):
@edwintorok
Copy link
Contributor Author

Screenshot from 2024-12-18 23-55-55
Not sure how to best capture the error from the LSP in a text form, so here is a screenshot of the error.

@gridbugs
Copy link
Collaborator

Thanks for the report! I was hoping that using a different linker between ocamllsp and the code being analyzed wouldn't be an issue but I might be wrong. Can you share what linux distro/version you're using so I can try setting up a similar environment in docker to reproduce/investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants