Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicting versions of merlin with the ocaml layer #6521

Closed
tizoc opened this issue Jul 6, 2016 · 10 comments
Closed

Conflicting versions of merlin with the ocaml layer #6521

tizoc opened this issue Jul 6, 2016 · 10 comments

Comments

@tizoc
Copy link

tizoc commented Jul 6, 2016

Description

The OCaml layer loads a Merlin from ELPA instead of the one installed by Opam, this causes problems if the merlin from ELPA and the Merlin installed by Opam are not the same version.

It seems the layer does try to load the version installed by Opam, but since Spacemacs also installs Merlin from ELPA it ends first in the load-path and given preference over the version installed by Opam. See https://github.com/syl20bnr/spacemacs/blob/master/layers/%2Blang/ocaml/funcs.el#L20

Reproduction guide

  • Start Emacs
  • With an outdated version of Merlin from ELPA, install a newer version of Merlin with Opam
  • Open an OCaml file
  • Look at it breaking

Observed behaviour:

The Emacs' side of Merlin fails to communicate with the Merlin process.

Described here ocaml/merlin#457 (not specific to Spacemacs, just having different versions for the elisp part of Merlin and the external Merlin process)

Expected behaviour:

For it to not fail

System Info

  • OS: darwin
  • Emacs: 24.4.1
  • Spacemacs: 0.105.21
  • Spacemacs branch: master (rev. 0283f64)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: emacs
  • Completion: helm
  • Layers:
((auto-completion :variables auto-completion-enable-help-tooltip t))

Backtrace

not relevant
@tizoc
Copy link
Author

tizoc commented Jul 6, 2016

A solution would be for the OCaml layer to not try to install Merlin at all, the elisp package alone is useless if the OCaml side is not installed, and if it is installed, then it comes with the matching elisp code, which the layer knows how to find already, it only breaks now because a conflicting Merlin package is installed from ELPA too.

@bixuanzju
Copy link
Contributor

bixuanzju commented Jul 7, 2016

On my machine, ocaml-load-path comes first than that from Melpa.

"/Users/jeremybi/.opam/system/share/emacs/site-lisp" ... "/Users/jeremybi/.emacs.d/elpa/merlin-20160627.1923" ...)

PS: I am using develop, perhaps you can try and see if it still the case.

@tizoc
Copy link
Author

tizoc commented Jul 7, 2016

Right now on my system the opam version comes first on my load-path too, but I don't know if that is always the case. I have been using spacemacs for months (since february I think?), and this was never a problem before, and the ELPA merlin version I had installed was pretty old. It only was a problem after I did a restart after upgrading from OSX 10.9 to 10.11 (probably unrelated but it is the only thing that changed before it stopped working).

Is there a way to figure out which merlin is loaded right now just to be sure?

@NJBS
Copy link
Contributor

NJBS commented Jul 7, 2016

I also see share/emacs/site-lisp before the melpa package.

@tizoc You can try M-x merlin-version if you have two different versions of merlin installed.

@tizoc
Copy link
Author

tizoc commented Jul 7, 2016

@NJBS it is 2.5.0 but the elisp code gets the version from the merlin command, the version is not part of the elisp code.

Note that the problem has gone away after I forced an upgrade to the ELPA version of merlin (which was months old), so the way things are setup now on my machine I cannot reproduce the problem anymore, even if the ELPA version is loaded things will work because it is up to date.

@NJBS
Copy link
Contributor

NJBS commented Jul 7, 2016

Ah, I see.

If it's first in your load-path it will use that, but if you really want to be sure you can try SPC h d f merlin-mode then selecting merlin.el should take you to the file it's using.

@tizoc
Copy link
Author

tizoc commented Jul 7, 2016

Thanks, I didn't occur to me to use that, but now that you mention it, it was obvious :)

It is weird, because the directory that contains merlin from opam comes first, and the files are there, but the merlin file that is pointed to from the function help is the one from ELPA: ~/.emacs.d/elpa/merlin-20160627.1923/merlin.el

But now I tried the locate-library command (which I just found), and if I use it and ask for merlin then it points me to the path to the opam one: Library is file ~/.opam/system/share/emacs/site-lisp/merlin.el

So, I did something else, to be sure I edited the merlin-version function in the ELPA merlin to include some extra data in the output and restarted emacs, then called merlin-version. The output was clean, which means the version that is being loaded is the one from opam (which is what I expected given the load-path order, but wanted to be sure).

I don't really know what else changed, but before deleting the old merlin version in the ELPA directory things weren't working, and my best guess is that the problem is that the old version in ELPA was being loaded instead of the opam version.

@d12frosted
Copy link
Collaborator

Does it work for you with latest versions?

@tizoc
Copy link
Author

tizoc commented Oct 31, 2016

@d12frosted I haven't experienced the problem anymore since I forced an upgrade of the merlin package.

@d12frosted
Copy link
Collaborator

Glad to hear that it's fixed! Thus closing this one 😸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Forum
  
To close
Development

No branches or pull requests

5 participants