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

merlin fails on startup in merlin/send-command-async #457

Closed
jbulow opened this Issue Oct 27, 2015 · 30 comments

Comments

Projects
None yet
7 participants
@jbulow

jbulow commented Oct 27, 2015

No matter what I type I get this or similar error in message buffer:

Error in merlin/send-command-async callback: (error "Command ((assoc) (context auto /Users/jonas/ocaml/test.ml) (query tell start at ((assoc) (line . 1) (col . 0)))) failed with error invalid arguments")
Error in merlin/send-command-async callback: (error "Command ((assoc) (context auto /Users/jonas/ocaml/test.ml) (query tell source-eof let x=3 in x+3;;

)) failed with error invalid arguments")

@let-def

This comment has been minimized.

Show comment
Hide comment
@let-def

let-def Oct 27, 2015

Contributor

Yes, it happens if you are mixing emacs mode from git with binary from opam.
Either use the emacs mode provided by opam or binary from git.

For the latter:

opam pin add merlin https://github.com/the-lambda-church/merlin.git
Contributor

let-def commented Oct 27, 2015

Yes, it happens if you are mixing emacs mode from git with binary from opam.
Either use the emacs mode provided by opam or binary from git.

For the latter:

opam pin add merlin https://github.com/the-lambda-church/merlin.git
@jbulow

This comment has been minimized.

Show comment
Hide comment
@jbulow

jbulow Oct 28, 2015

Running
opam pin add merlin https://github.com/the-lambda-church/merlin.git
outputs: (I'm new to OCaml and are just trying to set up an environment for learning)

#=== ERROR while installing merlin.2.2 ========================================#
# opam-version 1.2.2
# os           darwin
# command      make -j 1
# path         /Users/jonas/.opam/4.02.0/build/merlin.2.2
# compiler     4.02.0
# exit-code    2
# env-file     /Users/jonas/.opam/4.02.0/build/merlin.2.2/merlin-28197-a00279.env
# stdout-file  /Users/jonas/.opam/4.02.0/build/merlin.2.2/merlin-28197-a00279.out
# stderr-file  /Users/jonas/.opam/4.02.0/build/merlin.2.2/merlin-28197-a00279.err
### stdout ###
# /Applications/Xcode.app/Contents/Developer/usr/bin/make -f Makefile.ocamlmakefile WITH_BIN_ANNOT="" WITH_DEBUG="" REALLY_QUIET=1 ocamlmerlin
### stderr ###
# File "src/ocaml/typing/typecore.ml", line 3032, characters 10-16:
# Error: This variant pattern is expected to have type
#          (a, b, c, d, e, f, g, h, i, j, k, l)
#          CamlinternalFormatBasics.fmtty_rel
#        The constructor Any_ty does not belong to type CamlinternalFormatBasics.fmtty_rel
# Hint: Did you mean Int_ty?
# make[2]: *** [src/ocaml/typing/typecore.cmx] Error 2
# make[1]: *** [native-code] Error 2
# make: *** [ocamlmerlin] Error 2

jbulow commented Oct 28, 2015

Running
opam pin add merlin https://github.com/the-lambda-church/merlin.git
outputs: (I'm new to OCaml and are just trying to set up an environment for learning)

#=== ERROR while installing merlin.2.2 ========================================#
# opam-version 1.2.2
# os           darwin
# command      make -j 1
# path         /Users/jonas/.opam/4.02.0/build/merlin.2.2
# compiler     4.02.0
# exit-code    2
# env-file     /Users/jonas/.opam/4.02.0/build/merlin.2.2/merlin-28197-a00279.env
# stdout-file  /Users/jonas/.opam/4.02.0/build/merlin.2.2/merlin-28197-a00279.out
# stderr-file  /Users/jonas/.opam/4.02.0/build/merlin.2.2/merlin-28197-a00279.err
### stdout ###
# /Applications/Xcode.app/Contents/Developer/usr/bin/make -f Makefile.ocamlmakefile WITH_BIN_ANNOT="" WITH_DEBUG="" REALLY_QUIET=1 ocamlmerlin
### stderr ###
# File "src/ocaml/typing/typecore.ml", line 3032, characters 10-16:
# Error: This variant pattern is expected to have type
#          (a, b, c, d, e, f, g, h, i, j, k, l)
#          CamlinternalFormatBasics.fmtty_rel
#        The constructor Any_ty does not belong to type CamlinternalFormatBasics.fmtty_rel
# Hint: Did you mean Int_ty?
# make[2]: *** [src/ocaml/typing/typecore.cmx] Error 2
# make[1]: *** [native-code] Error 2
# make: *** [ocamlmerlin] Error 2
@let-def

This comment has been minimized.

Show comment
Hide comment
@let-def

let-def Oct 28, 2015

Contributor

I recommend switching to a more recent version of OCaml, e.g. opam switch 4.02.3.
It is compatible with 4.02.0, with important bug fixes (and some internal changes that won't matter if you are a beginner).

Contributor

let-def commented Oct 28, 2015

I recommend switching to a more recent version of OCaml, e.g. opam switch 4.02.3.
It is compatible with 4.02.0, with important bug fixes (and some internal changes that won't matter if you are a beginner).

@jbulow

This comment has been minimized.

Show comment
Hide comment
@jbulow

jbulow Oct 28, 2015

Switching to OCaml 4.02.3 solved the installation problem of merlin.

I don't really understand why I got this problem. I just followed the official installation instructions. What did I miss? What do you mean when you say I'm mixing emacs mode from git with binary from opam?

jbulow commented Oct 28, 2015

Switching to OCaml 4.02.3 solved the installation problem of merlin.

I don't really understand why I got this problem. I just followed the official installation instructions. What did I miss? What do you mean when you say I'm mixing emacs mode from git with binary from opam?

@jbulow

This comment has been minimized.

Show comment
Hide comment
@jbulow

jbulow Oct 28, 2015

..but now utop broke:

opam config exec utop -- -emacs
Fatal error: exception # opam-version    1.2.2
# os              darwin
opam: "execvp" failed on utop: No such file or directory

% utop
Fatal error: the file '/Users/jonas/.opam/system/bin/utop' is not a bytecode executable file

% which utop
/Users/jonas/.opam/system/bin/utop

% file /Users/jonas/.opam/system/bin/utop
/Users/jonas/.opam/system/bin/utop: a /opt/local/bin/ocamlrun script text executable

What is the correct way of upgrading the OCaml version without breaking everything else? I used the command you recommended.

jbulow commented Oct 28, 2015

..but now utop broke:

opam config exec utop -- -emacs
Fatal error: exception # opam-version    1.2.2
# os              darwin
opam: "execvp" failed on utop: No such file or directory

% utop
Fatal error: the file '/Users/jonas/.opam/system/bin/utop' is not a bytecode executable file

% which utop
/Users/jonas/.opam/system/bin/utop

% file /Users/jonas/.opam/system/bin/utop
/Users/jonas/.opam/system/bin/utop: a /opt/local/bin/ocamlrun script text executable

What is the correct way of upgrading the OCaml version without breaking everything else? I used the command you recommended.

@let-def

This comment has been minimized.

Show comment
Hide comment
@let-def

let-def Oct 28, 2015

Contributor

Don't use the system switch, installer utop in the current one (opam install utop)

Contributor

let-def commented Oct 28, 2015

Don't use the system switch, installer utop in the current one (opam install utop)

@jbulow

This comment has been minimized.

Show comment
Hide comment
@jbulow

jbulow Oct 28, 2015

What is the system switch? I used opam switch 4.02.3

utop was installed before switching to 4.02.3. I tried to reinstall it with opam install utop but it is still broken.

jbulow commented Oct 28, 2015

What is the system switch? I used opam switch 4.02.3

utop was installed before switching to 4.02.3. I tried to reinstall it with opam install utop but it is still broken.

@let-def

This comment has been minimized.

Show comment
Hide comment
@let-def

let-def Oct 28, 2015

Contributor

A switch is a separate installation of OCaml, either to have different versions in parallel, to maintain a separate set of packages, whatever...

The system switch is the one maintained by the system (e.g. package manager, brew, macports, ...) and not by opam.

Your version of utop was tied to system switch (as pointed out by the path in your error message: .opam/system), apparently conflicting with the recent installation of 4.02.3.

Dev tools are especially tied to a version of the compiler, it is better to install them in each switcj.

Contributor

let-def commented Oct 28, 2015

A switch is a separate installation of OCaml, either to have different versions in parallel, to maintain a separate set of packages, whatever...

The system switch is the one maintained by the system (e.g. package manager, brew, macports, ...) and not by opam.

Your version of utop was tied to system switch (as pointed out by the path in your error message: .opam/system), apparently conflicting with the recent installation of 4.02.3.

Dev tools are especially tied to a version of the compiler, it is better to install them in each switcj.

@let-def

This comment has been minimized.

Show comment
Hide comment
@let-def

let-def Oct 28, 2015

Contributor

In what way is it still broken after reinstall?
Are you sure your shell is properly setup?

Contributor

let-def commented Oct 28, 2015

In what way is it still broken after reinstall?
Are you sure your shell is properly setup?

@let-def

This comment has been minimized.

Show comment
Hide comment
@let-def

let-def Oct 28, 2015

Contributor

(If you don't mind, please share the output of env shell command)

Contributor

let-def commented Oct 28, 2015

(If you don't mind, please share the output of env shell command)

@jbulow

This comment has been minimized.

Show comment
Hide comment
@jbulow

jbulow Oct 28, 2015

A simple "rehash" solved the problem.

I really appreciate your help! It's quite hard to get into the OCaml ecosystem :-)

jbulow commented Oct 28, 2015

A simple "rehash" solved the problem.

I really appreciate your help! It's quite hard to get into the OCaml ecosystem :-)

@gasche

This comment has been minimized.

Show comment
Hide comment
@gasche

gasche Oct 28, 2015

Member

I really appreciate your help! It's quite hard to get into the OCaml ecosystem :-)

You're not the only one coming to this conclusion, but unfortunately it's rather difficult to improve things -- we can only do it bits by bits and it requires a lot of small things to improve. One of the problem is that the switch mechanism is devilishly convenient for advanced users but rather impenetrable to adopters -- and it's even worse for some beginners that are comfortable using their system but don't have much of a mental model of UNIX environments and their consequences.

Member

gasche commented Oct 28, 2015

I really appreciate your help! It's quite hard to get into the OCaml ecosystem :-)

You're not the only one coming to this conclusion, but unfortunately it's rather difficult to improve things -- we can only do it bits by bits and it requires a lot of small things to improve. One of the problem is that the switch mechanism is devilishly convenient for advanced users but rather impenetrable to adopters -- and it's even worse for some beginners that are comfortable using their system but don't have much of a mental model of UNIX environments and their consequences.

@let-def

This comment has been minimized.

Show comment
Hide comment
@let-def

let-def Oct 28, 2015

Contributor

As @gasche said.

And to reply to you earlier question: merlin comes in different parts. In your case, the binary (ocamlmerlin) and the emacs mode.
The protocol between the two sometime changes, and so both have to be kept in sync.
I would guess that you installed the merlin mode from melpa, which sadly targets the git master and is more recent than opam the package (although a release is being prepared).

Contributor

let-def commented Oct 28, 2015

As @gasche said.

And to reply to you earlier question: merlin comes in different parts. In your case, the binary (ocamlmerlin) and the emacs mode.
The protocol between the two sometime changes, and so both have to be kept in sync.
I would guess that you installed the merlin mode from melpa, which sadly targets the git master and is more recent than opam the package (although a release is being prepared).

@let-def let-def closed this Oct 28, 2015

@gasche

This comment has been minimized.

Show comment
Hide comment
@gasche

gasche Oct 28, 2015

Member

@def-lkb , would it be possible to embed versioning in the Merlin protocol to give a clear error message to users in this case?

Member

gasche commented Oct 28, 2015

@def-lkb , would it be possible to embed versioning in the Merlin protocol to give a clear error message to users in this case?

@jbulow

This comment has been minimized.

Show comment
Hide comment
@jbulow

jbulow Oct 28, 2015

Ironically, I consider myself as quite used to UNIX-like system from having different kind of UNIX-systems as my primary platform of choice since the last 20 years. :-)

It's hard to point on a single aspect of the OCaml ecosystem that makes it harder than other languages. In this case it was a combination of the "sorry state" of the package system in emacs ( http://blog.jorgenschaefer.de/2014/06/the-sorry-state-of-emacs-lisp-package.html ) and the somewhat obscure opam package system that did not play well together. On top of that I made it even harder by using a shell (tcsh) that need an explicit rescan when the PATH changes.

jbulow commented Oct 28, 2015

Ironically, I consider myself as quite used to UNIX-like system from having different kind of UNIX-systems as my primary platform of choice since the last 20 years. :-)

It's hard to point on a single aspect of the OCaml ecosystem that makes it harder than other languages. In this case it was a combination of the "sorry state" of the package system in emacs ( http://blog.jorgenschaefer.de/2014/06/the-sorry-state-of-emacs-lisp-package.html ) and the somewhat obscure opam package system that did not play well together. On top of that I made it even harder by using a shell (tcsh) that need an explicit rescan when the PATH changes.

@gasche

This comment has been minimized.

Show comment
Hide comment
@gasche

gasche Oct 28, 2015

Member

Apologies for being unclear and possibly irritating: I wasn't assuming that you were in that category (in fact it's quite clear from the quality of your failure reports that you aren't), but thinking of other people I've helped that had even more trouble.

Member

gasche commented Oct 28, 2015

Apologies for being unclear and possibly irritating: I wasn't assuming that you were in that category (in fact it's quite clear from the quality of your failure reports that you aren't), but thinking of other people I've helped that had even more trouble.

@ethanluoyc

This comment has been minimized.

Show comment
Hide comment
@ethanluoyc

ethanluoyc Jul 4, 2016

Hi I am coming from the Spacemacs community and I encountered the same problem again with the Ocaml layer.

I installed my ocaml and OPAM with Homebrew and I also followed the solution above and installed a switch of the OCaml and pinned a version of the Merlin as suggested. Still I encountered the same problem.

The error message is included below:

Error in merlin/send-command-async callback: (error "Command ((assoc) (context auto /Users/Ethan/dev/playground/ocaml/counter.ml) (query tell start at ((assoc) (line . 1) (col . 0)))) failed with error invalid arguments")

which ocamlmerlin gives /Users/Ethan/.opam/4.02.3/bin/ocamlmerlin from opam list it indeed shows that I am using the pinned version of Merlin (v2.5.0) Unlike the Emacs instruction I did not include the script in order to find Merlin-related modes as I figure that the OCaml layer probably has handled that for me.

Any idea how this might be the case?

ethanluoyc commented Jul 4, 2016

Hi I am coming from the Spacemacs community and I encountered the same problem again with the Ocaml layer.

I installed my ocaml and OPAM with Homebrew and I also followed the solution above and installed a switch of the OCaml and pinned a version of the Merlin as suggested. Still I encountered the same problem.

The error message is included below:

Error in merlin/send-command-async callback: (error "Command ((assoc) (context auto /Users/Ethan/dev/playground/ocaml/counter.ml) (query tell start at ((assoc) (line . 1) (col . 0)))) failed with error invalid arguments")

which ocamlmerlin gives /Users/Ethan/.opam/4.02.3/bin/ocamlmerlin from opam list it indeed shows that I am using the pinned version of Merlin (v2.5.0) Unlike the Emacs instruction I did not include the script in order to find Merlin-related modes as I figure that the OCaml layer probably has handled that for me.

Any idea how this might be the case?

@tizoc

This comment has been minimized.

Show comment
Hide comment
@tizoc

tizoc Jul 6, 2016

@ethanluoyc I just had this same issue, turns out spacemacs' had its own copy of merlin in its elpa directory, which is what was being loaded instead of the one installed by opam.

Upgrading it should fix the issue: use the [Update Packages] "button" found in spacemacs' starting page or if you don't want to have everything updated do like I did and delete ~/.emacs.d/elpa/merlin-* and restart emacs).

The ocaml layer is supposed to use the version installed by opam (https://github.com/syl20bnr/spacemacs/blob/master/layers/%2Blang/ocaml/funcs.el#L20) but it is not working correctly (the elpa version is being put first in the load-path).

tizoc commented Jul 6, 2016

@ethanluoyc I just had this same issue, turns out spacemacs' had its own copy of merlin in its elpa directory, which is what was being loaded instead of the one installed by opam.

Upgrading it should fix the issue: use the [Update Packages] "button" found in spacemacs' starting page or if you don't want to have everything updated do like I did and delete ~/.emacs.d/elpa/merlin-* and restart emacs).

The ocaml layer is supposed to use the version installed by opam (https://github.com/syl20bnr/spacemacs/blob/master/layers/%2Blang/ocaml/funcs.el#L20) but it is not working correctly (the elpa version is being put first in the load-path).

@ethanluoyc

This comment has been minimized.

Show comment
Hide comment
@ethanluoyc

ethanluoyc Jul 7, 2016

Yes, after a reinstall the problem seems to go away.

On Thu, Jul 7, 2016 at 5:19 AM +0800, "tizoc" notifications@github.com wrote:

@ethanluoyc I just had this same issue, turns out spacemacs' had its own copy of merlin in its elpa directory, which is what was being loaded instead of the one installed by opam.

Upgrading it should fix the issue: use the [Update Packages] "button" found in spacemacs' starting page or if you don't want to have everything updated do like I did and delete ~/.emacs.d/elpa/merlin-* and restart emacs).

The ocaml layer is supposed to use the version installed by opam (https://github.com/syl20bnr/spacemacs/blob/master/layers/%2Blang/ocaml/funcs.el#L20) but it is not working correctly (the elpa version is being put first in the load-path).


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

ethanluoyc commented Jul 7, 2016

Yes, after a reinstall the problem seems to go away.

On Thu, Jul 7, 2016 at 5:19 AM +0800, "tizoc" notifications@github.com wrote:

@ethanluoyc I just had this same issue, turns out spacemacs' had its own copy of merlin in its elpa directory, which is what was being loaded instead of the one installed by opam.

Upgrading it should fix the issue: use the [Update Packages] "button" found in spacemacs' starting page or if you don't want to have everything updated do like I did and delete ~/.emacs.d/elpa/merlin-* and restart emacs).

The ocaml layer is supposed to use the version installed by opam (https://github.com/syl20bnr/spacemacs/blob/master/layers/%2Blang/ocaml/funcs.el#L20) but it is not working correctly (the elpa version is being put first in the load-path).


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@xguerin

This comment has been minimized.

Show comment
Hide comment
@xguerin

xguerin Sep 25, 2016

Contributor

When pinning merlin in opam, running emacs -Q and loading both tuareg and merlin, I get the same error, except "failed with error nil". I am using emacs 24.5.1 on OpenBSD 6.0. My compiler version is 4.03.

EDIT Please disregard. The problem came from a development version of a PPX package that was not properly packaged. Merlin count not find the PPX executable. A cleaner message error could probably be found though.

Contributor

xguerin commented Sep 25, 2016

When pinning merlin in opam, running emacs -Q and loading both tuareg and merlin, I get the same error, except "failed with error nil". I am using emacs 24.5.1 on OpenBSD 6.0. My compiler version is 4.03.

EDIT Please disregard. The problem came from a development version of a PPX package that was not properly packaged. Merlin count not find the PPX executable. A cleaner message error could probably be found though.

@zbroyar

This comment has been minimized.

Show comment
Hide comment
@zbroyar

zbroyar Mar 1, 2017

Hi,

Just met almost the same problem. I have just one merlin.el and it's correctly placed in ~/.opam/4.03.0/share/emacs/site-lisp/merlin.el

Ubuntu 16.04, Emacs 24.5.1, Merlin 2.5.3

% cat .merlin
S .
B ./_build
PKG atdgen yojson biniou curl pcre unix cryptokit netclient
PKG smtp ssl ocplib-endian nocrypto pgocaml pgocaml.syntax
PKG lacaml ppx_deriving pgocaml.ppx mybuild deriving
%

Error in merlin/send-command-async callback: (error "Command ((assoc) (document auto /home/z/proj/test/test.ml) (query protocol version 3)) failed with error nil")
Error in merlin/send-command-async callback: (error "Command ((assoc) (document auto /home/nick/proj/imitation/depth.ml) (query tell start end open Local )) failed with error nil")

Please, help

zbroyar commented Mar 1, 2017

Hi,

Just met almost the same problem. I have just one merlin.el and it's correctly placed in ~/.opam/4.03.0/share/emacs/site-lisp/merlin.el

Ubuntu 16.04, Emacs 24.5.1, Merlin 2.5.3

% cat .merlin
S .
B ./_build
PKG atdgen yojson biniou curl pcre unix cryptokit netclient
PKG smtp ssl ocplib-endian nocrypto pgocaml pgocaml.syntax
PKG lacaml ppx_deriving pgocaml.ppx mybuild deriving
%

Error in merlin/send-command-async callback: (error "Command ((assoc) (document auto /home/z/proj/test/test.ml) (query protocol version 3)) failed with error nil")
Error in merlin/send-command-async callback: (error "Command ((assoc) (document auto /home/nick/proj/imitation/depth.ml) (query tell start end open Local )) failed with error nil")

Please, help

@tizoc

This comment has been minimized.

Show comment
Hide comment
@tizoc

tizoc Mar 1, 2017

@zbroyar are you using spacemacs? if thats the case, try deleting the merlin directory in your emacs' .elpa directory and have spacemacs reinstall it again. See syl20bnr/spacemacs#6521

tizoc commented Mar 1, 2017

@zbroyar are you using spacemacs? if thats the case, try deleting the merlin directory in your emacs' .elpa directory and have spacemacs reinstall it again. See syl20bnr/spacemacs#6521

@zbroyar

This comment has been minimized.

Show comment
Hide comment
@zbroyar

zbroyar Mar 1, 2017

@tizoc nope, it's the usual emacs installed by "apt-get install"

zbroyar commented Mar 1, 2017

@tizoc nope, it's the usual emacs installed by "apt-get install"

@let-def

This comment has been minimized.

Show comment
Hide comment
@let-def

let-def Mar 1, 2017

Contributor

What is the output of M-X merlin-version?

Contributor

let-def commented Mar 1, 2017

What is the output of M-X merlin-version?

@zbroyar

This comment has been minimized.

Show comment
Hide comment
@zbroyar

zbroyar commented Mar 1, 2017

@let-def it's nil

@let-def

This comment has been minimized.

Show comment
Hide comment
@let-def

let-def Mar 1, 2017

Contributor

What about M-x shell-command which ocamlmerlin?

Contributor

let-def commented Mar 1, 2017

What about M-x shell-command which ocamlmerlin?

@zbroyar

This comment has been minimized.

Show comment
Hide comment
@zbroyar

zbroyar Mar 1, 2017

Right now I see ocamlmerlin started from correct location.

zbroyar commented Mar 1, 2017

Right now I see ocamlmerlin started from correct location.

@zbroyar

This comment has been minimized.

Show comment
Hide comment
@zbroyar

zbroyar Mar 1, 2017

But shell-command which ocamlmerlin gives me "file not found"

zbroyar commented Mar 1, 2017

But shell-command which ocamlmerlin gives me "file not found"

@let-def

This comment has been minimized.

Show comment
Hide comment
@let-def

let-def Mar 1, 2017

Contributor

Probably your PATH is just not setup. You can set it explicitly with M-x customize-variable merlin-command.

Contributor

let-def commented Mar 1, 2017

Probably your PATH is just not setup. You can set it explicitly with M-x customize-variable merlin-command.

@zbroyar

This comment has been minimized.

Show comment
Hide comment
@zbroyar

zbroyar Mar 1, 2017

@let-def thanks for your help and time. The problem was in my .emacs: somehow I put there second setenv command with wrong parameters.

zbroyar commented Mar 1, 2017

@let-def thanks for your help and time. The problem was in my .emacs: somehow I put there second setenv command with wrong parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment