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

I/O error with files in a subdirectory

Open grayswandyr opened this issue 4 years ago • 9 comments

Hi, first: thanks for your efforts in improving the OCaml developer experience.

I'm using Codium (a variant of VS Code without MS' telemetry). The structure of my (private) project features an src/ dir as well as an src/test/ subdir (with ppx_expect tests only). There is a dune file in src/ with, in particular, the (include_subdirs unqualified) instruction. In the auto-generated src/.merlin, I have S . and S test.

However, Codium shows an error message in the "Problems" pane, issued by ocaml-lsp, for every file lying in src/test:

I/O error: test_foo.ml: No such file or directory
ocamllsp [2, 1]

However, dune builds and runs tests without any issue.

Also, if test_foo.ml is moved to src, Codium/ocaml-lsp shows no more error.

So it's fortunately not a show-stopper but I guess it may indicate a problem to be solved.

grayswandyr avatar Oct 26 '20 16:10 grayswandyr

I can replicate this with a somewhat minimal example. Not related to include_subdirs it triggers seemingly depending on levels of dir path, ie path is stripped somewhere. This is only for ppx_expect tests, ppx_inline_test works fine.

I/O error: example_a.ml: No such file or
directory

This is only shows in vscode/lsp. dune works fine.

For below project

  • ppx_expect test is ok in ./lspbug/lib/
  • ppx_expect test is fails in viscose with "" in ./lspbug/lib/a/
  • ppx_inline tests work in all cases.
├── dune-project
└── lspbug
    └── lib
        ├── a
        │   ├── dune
        │   └── example_a.ml
        ├── dune
        └── example.ml

I'm not able to run ocamllsp with logging output.

lspbug/lib/dune

(library
 (inline_tests)
 (name lspbug_root)
 (preprocess
  (pps ppx_inline_test ppx_expect)))

lspbug/lib/a/dune:

(library
 (inline_tests)
 (name lspbug_a)
 (preprocess
  (pps ppx_inline_test ppx_expect)))

example.ml/example_a.ml

let%expect_test _ = print_endline "foo"

frejsoya avatar Feb 02 '21 07:02 frejsoya

This seems to an unresolved issue with merlin: https://github.com/ocaml/merlin/issues/1095

frejsoya avatar Feb 02 '21 07:02 frejsoya

Maybe I messed up in previous example, please ignore: The following does not work using ppx_expect

├── a
│   ├── dune
│   └── example_a.ml
└── dune-project

This does

├── dune
├── example_a.ml
└── dune-project

frejsoya avatar Feb 02 '21 10:02 frejsoya

This is the logging output from vscode<->ocamllsp after restart, attached.

ocamllsp.log

frejsoya avatar Feb 03 '21 10:02 frejsoya

Alternatively.

Simply open this project (ocaml-lsp) with vscode and ocaml-platform extension and open a file that uses with ppx_expect. Ie. fiber-unix/test/barrier_test.ml

frejsoya avatar Feb 03 '21 14:02 frejsoya

I'm seeing this too and it appears to be a relatively new regression since it only started happening recently, my underlying project code hasn't changed.

ryanslade avatar Feb 19 '21 07:02 ryanslade

Any news/workaround for this issue?

wokalski avatar Nov 17 '21 20:11 wokalski

Can this bug still be reproduced in master?

rgrinberg avatar Nov 19 '21 05:11 rgrinberg

This seems to be fixed in master.

wokalski avatar Dec 21 '21 22:12 wokalski