Dune ppx_expect and merlin(ocaml-lsp) not working

I am using expect_tests in my module, however I am getting the error below from possibly (??) merlin/ocaml-lsp.

My dune file:

(library
 (name lib1)
 (public_name lib1)
 (inline_tests)
 (preprocess
  (pps ppx_expect ppx_inline_test)))

ppx_expect: extension is disabled because the tests would be ignored (the build system didn’t pass -inline-test-lib)

Is there some setting that I need to configure?

The dune stanza looks good.

Are you using recent versions of dune and ppx_expect?

dune : 2.7.1
ppx_expect: 0.14.1
ocamllsp : 1.2.0

same error with both vscode/ocamllsp and merlin.

Note: dune runtest works correctly, i.e. no errors or warnings.

Not sure if this is helpful but the error seems to have resolved if I install ppx_deriving version 5.1. So when installing ppx_deriving 5.1, it downgrades the following packages,

↘ downgrade ocaml-migrate-parsetree 2.1.0 to 1.8.0     [required by ppx_deriving]
↘ downgrade ppxlib                  0.20.0 to 0.15.0   [required by ppx_deriving]
↘ downgrade ocamlformat             0.16.0 to 0.15.0   [uses ocaml-migrate-parsetree]
↘ downgrade ppx_expect              v0.14.1 to v0.14.0 [uses ppxlib]

So I am guessing the issue is in one of the packages above and not dune/ocaml-lsp per se.

1 Like

I don’t have a solution, but I’d like to mention that somebody recently filed an issue for the same problem: https://github.com/ocaml/ocaml-lsp/issues/310

I have been unable to fix this by downgrading versions for some time. Both newer versions are broken and the above versions are not working for me. Ocamllsp+vscode is the only place I can replicate this. Dune works just fine.

I’d be happy to spend some to fix, but I am currently stuck debugging what’s going on. 1) The error has no location information or call-stack. 2) Simple print/logging to a file seems to break ocamllsp/vscode as it halts/blocks further progress.

Just in case, the error from ocamllsp is:

[Trace - 12:05:32] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///Users/frej/git/ocaml-lsp/fiber-unix/test/barrier_tests.ml",
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 1,
                    "character": 0
                },
                "end": {
                    "line": 2,
                    "character": 0
                }
            },
            "severity": 1,
            "source": "ocamllsp",
            "message": "I/O error: barrier_tests.ml: No such file or\ndirectory"
        }
    ]
}

Simply removing all ppx_expect tests in a file removed the error

This was due to a bug in ppxlib. It was fixed in ppxlib 0.21.0. However, we recently found another issue with merlin and ppx_expect, which is fixed by this PR: Fix workdir detection by voodoos · Pull Request #1284 · ocaml/merlin · GitHub

1 Like

Thanks @jeremiedimino I had a hunch moving away from .merlin and relative paths was a potential reason. Finding where in the stack was harder :slight_smile: