Hey, I’m using VSCode and seeing an error when using the OCaml extension on my files: I’m trying to run the OCaml version into v5.1.1
.
Corrupted compiled interface ~/.opam/5.1.1/lib/ocaml/stdlib.cmi
In case, I can run the dune build
without any problem and it can be executed, but I’m trying to understand why it’s happening? Any idea why?
BTW, I’m using macOS + Nix Flakes to run this OCaml project. I put here how my flake.nix
has been wrote:
{
description = "A development environment for ocaml";
inputs = {
nixpkgs.url = "github:nix-ocaml/nix-overlays";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages."${system}".extend (self: super: {
ocamlPackages = super.ocaml-ng.ocamlPackages_5_1;
});
ocamlPackages = pkgs.ocamlPackages;
packages = [
ocamlPackages.brr
ocamlPackages.utop
ocamlPackages.ocamlformat
ocamlPackages.ocaml
ocamlPackages.dune
ocamlPackages.opam
ocamlPackages.ocaml-lsp
ocamlPackages.merlin
];
in
{
formatter = nixpkgs.legacyPackages.x86_64-linux.nixpkgs-fmt;
defaultPackage = pkgs.stdenv.mkDerivation {
name = "ocamlbyexample";
src = ./.;
};
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs.ocamlPackages; [ cppo findlib ];
buildInputs = with pkgs; [
packages
caddy
curl
wget
];
shellHook = ''
export OPAMCURL="curl"
'';
};
}
);
}
Any idea how to debug it and why it’s happening?
I think that can have some relationship with my setup, because when I run the opam install ppx_inline_test
, it display a similar error related to:
# File "src/sexp.mli", line 1:
# Error: The files ~/.opam/5.1.1/lib/ocaml/stdlib.cmi
# and /nix/store/hash-ocaml5.1.1-sexplib0-0.17.0/lib/ocaml/5.1.1/site-lib/sexplib0/sexplib0.cmi
# make inconsistent assumptions over interface Stdlib