Skip to content

Feature Request: Use single .merlin file even when subprojects have dune-project or dune-workspace #1869

@jonahbeckford

Description

@jonahbeckford

Summary

Merlin does not have a way to express using a single .merlin file at the root of a unified project. That means vendored subprojects that have their own dune-project (or dune-workspace) spawn their own dune ocaml-merlin processes and consequently mess up the Merlin configuration, even though there is a single build directory. I suspect this is an issue with opam-monorepo style projects as well.

Reproduction

I am converting some of my build systems (MlFront/DkCoder) to create .merlin files directly. As I transition I have a mix of dune-project and .merlin files. Here is the pertinent structure for one of the projects:

.merlin
#s/
  findlib.conf
src/
  SonicScout_Setup/
    AndroidStudio.ml
us/SonicScoutBackend/
  dune-project
  src/
    SonicScout_Std/
      Aws_manager.ml

Then when I do (PowerShell syntax):

get-content us\SonicScoutBackend\src\SonicScout_Std\Aws_manager.ml | `
.ci\cmake\bin\cmake -E env `
  OCAMLFIND_CONF=Y:\source\scoutapps\#s\findlib.conf `
  --modify PATH=path_list_prepend:Y:/source/dksdk-coder/build/d/o/two/bin `
  -- `
  Y:\source\dksdk-coder\build\d\o\one\.opam-switch\build\merlin.4.14-414\_build\install\default\bin\ocamlmerlin.exe `
  single dump-configuration `
    -filename us\SonicScoutBackend\src\SonicScout_Std\Aws_manager.ml `
  | jq '.value.merlin.failures, (.value.merlin.build_path | length)'

I get a failure:

[
  "No config found for file us/SonicScoutBackend/src/SonicScout_Std/Aws_manager.ml. Try calling 'dune build'."
]
0

When I remove the us/SonicScoutBackend/dune-project I get success (no failures and many build paths):

[]
227

Mitigation

I can't remove the dune-project. But I'll try to submit a PR that will be somewhat hacky since I don't know a clean way to solve this: #1870

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions