merlin icon indicating copy to clipboard operation
merlin copied to clipboard

"unknown flag '-package'" when running "merlin-use" since 3.3.7

Open eugecm opened this issue 5 years ago • 4 comments

Using ocaml 3.10.1 and merlin 4.10.1 I get the following error when running the merlin-use command on emacs:

unknown flag "-package"

It looks like the ocamlmerlin command is being constructed with a -package option, as can be seen in this line https://github.com/ocaml/merlin/blob/e0a3061e2c13748928bc77b5dc20ce207ad1218d/emacs/merlin.el#L496

However, said flag is not referenced in the source code other than in the emacs file since 7a45a1f99ea88e68b35ad67aa67d4455caa50523 according to git-bisect

Works fine in merlin 3.3.6

eugecm avatar Oct 25 '20 20:10 eugecm

Thanks for your precise report. We indeed dropped support for the -package flag and thus the merlin-use feature when moving to external configuration reader. The recommended way to indicate packages it to use the .merlin file.

However, crashing is not a good option and an informative message should be displayed instead.

voodoos avatar Nov 05 '20 15:11 voodoos

@voodoos is there a reason why -package was dropped? It'd be very useful to me in some contexts where merlin isn't invoked via dune.

c-cube avatar Feb 18 '21 21:02 c-cube

One of the reasons for using external configuration readers was to make the core of Merlin free of its ocamlfind dependency and this feature also depended on it.

However I heard that @let-def was planning to reintroduce that feature directly in the editor plugins

voodoos avatar Feb 19 '21 09:02 voodoos

The last release of Merlin introduce a new editor-side "merlin use" commands by @def.

Can you confirm if these answer to your use cases ?

Merlin used to support the -package flag to load an ocamlfind/findlib package. This was exposed by the :MerlinUse and merlin-use commands in vim and emacs.

The commands are still there but the support for -package was dropped when packaging logic was moved to dune (via the reader helper). So they are broken in the latest release...

This PR reimplements the command so they work entirely on editor side: ocamlfind is invoked to list packages and resolve package names to include path. Only theses paths are passed to merlin using the -I flag.

Tradeoffs:

  • ocamlfind is called from the editor environment... the answers might be out of date if the user changed to another opam switch. Workaround: maybe we should call opam exec ocamlfind instead of ocamlfind? (That's much slower... but maybe we shouldn't mind?)
  • only the include path is considered... This won't work with ppx and other fancy features supported by ocamlfind. I don't mind these use cases, any thoughts?

voodoos avatar Apr 15 '21 09:04 voodoos