gcv / julia-snail

An Emacs development environment for Julia
GNU General Public License v3.0
236 stars 23 forks source link

Error starting Julia Snail #42

Closed khyox closed 3 years ago

khyox commented 3 years ago

First of all, thank you very much for Julia Snail. Awesome integration of Emacs and Julia!

This is the issue that I am finding in the basic usage steps: After C-c C-z, I see:

julia> JuliaSnail.start(10011);

But I am getting the following error message:

Base.Meta.ParseError("missing comma or ) in argument list")                     

parse(::String, ::Int64; greedy::Bool, raise::Bool, depwarn::Bool) at meta.jl:184
parse at meta.jl:176 [inlined]                                                  
parse(::String; raise::Bool, depwarn::Bool) at meta.jl:215                      
parse(::String) at meta.jl:215                                                  
macro expansion at JuliaSnail.jl:540 [inlined]                                  
(::Main.JuliaSnail.var"#33#38"{Sockets.TCPSocket})() at task.jl:356

However, C-c C-k sends and executes the buffer with the julia program, so I am not sure what is really failing (since I have not had the occasion to see it work without this problem). Thanks!

Further details:

gcv commented 3 years ago

That’s really strange. I wonder if it’s the “vterm must be installed first” problem (described here: https://github.com/gcv/julia-snail/issues/38#issuecomment-683330697). Please check the size of the julia-snail.elc file in the installation directory and post it here. If it’s really small (a few hundred bytes; it should be several tens of kilobytes), then just reinstall Snail (you may need to restart Emacs).

khyox commented 3 years ago

Thanks for the reply! Since it was a fresh installation, I followed your guide step by step and installed vterm just before from MELPA (vterm release is 20201118.849). Vterm seems to be operating normally (except for a pasting issue on the vterm buffer that is initially set as read-only, but I guess this is totally unrelated).

This is the location and size of julia-snail.el:

 > ll ~/.emacs.d/elpa/julia-snail-20201117.712/julia-snail.el                     
-rw-r--r-- 1 user group 46K Nov 18 19:07 .emacs.d/elpa/julia-snail-20201117.712/julia-snail.el

It has 1070 lines, looks good, and finishes with:

(...)
;;; --- done                                                                

(provide 'julia-snail)                                                          

;;; julia-snail.el ends here

Thanks!

gcv commented 3 years ago

That’s julia-snail.el. What about julia-snail.elc? That’s the byte-code compiled file that takes precedence over the Elisp source file if it exists.

khyox commented 3 years ago

Sorry!

 > ll ~/.emacs.d/elpa/julia-snail-20201117.712/julia-snail.elc
-rw-r----- 1 user group 49K Nov 18 19:07 .emacs.d/elpa/julia-snail-20201117.712/julia-snail.elc
gcv commented 3 years ago

That looks about right, so we'll have to dig deeper. I just pushed a change which adds a little more debugging information. Please update julia-snail from MELPA, and restart Emacs.

  1. Try starting Snail. If the error doesn't occur, then it's the byte-code compiler after all.

  2. If the error still happens, quit Snail and execute (setq julia-snail-debug t) (using M-: or something similar). Then try starting Snail again. Right after you get that error message, switch to the *julia* process buffer and paste (or attach) its contents here.

For reference, mine looks something like this:

(ns = [:Main], reqid = "da5d0cdd", code = "normpath(joinpath(VERSION ≤ v\"0.7-\" ? JULIA_HOME : Sys.BINDIR, Base.DATAROOTDIR, \"julia\", \"base\"))")
(julia-snail--response-success "da5d0cdd" "/opt/Julia-1.5.3.app/Contents/Resources/julia/share/julia/base")

On Snail startup, Emacs asks the Julia process where to find .jl files which ship with Julia itself so xref to built-in functions works. Since you see the error on startup that has to be the thing which fails. In debug mode, the process buffer should contain the full code being evaluated, which seems to be where the error occurs.

khyox commented 3 years ago

Many thanks @gcv.

I followed the steps and the error still happens. I am pasting below the contents of the *julia* process buffer:

(ns = [:Main], reqid = "6ad2a139", code = "normpath(joinpath(VERSION ≤ v\"0.7-\" ? JULIA_HOME : Sys.BINDIR, Base.DATAROOTDIR, \"julia\", \"base\"))")
(julia-snail--response-failure "6ad2a139" "Base.Meta.ParseError(\"missing comma or ) in argument list\")" '("parse(::String, ::Int64; greedy::Bool, raise::Bool, depwarn::Bool) at meta.jl:184" "parse at meta.jl:176 [inlined]" "parse(::String; raise::Bool, depwarn::Bool) at meta.jl:215" "parse(::String) at meta.jl:215" "macro expansion at JuliaSnail.jl:540 [inlined]" "(::Main.JuliaSnail.var\"#33#38\"{Sockets.TCPSocket})() at task.jl:356"))

As before, I proceeded to use C-c C-k to send the julia source and it continued to work, so whatever the source of the error is does not affect that.

Thanks!

gcv commented 3 years ago

Since this is the only thing evaluating, then the breakage will only affect your ability to use xref to built-in functions. However, it's still strange and it would be good to get to the bottom of it.

Maybe there's a Unicode problem with ? What happens if you paste the following into the Julia REPL:

eval(Meta.parse("normpath(joinpath(VERSION ≤ v\"0.7-\" ? JULIA_HOME : Sys.BINDIR, Base.DATAROOTDIR, \"julia\", \"base\"))"))

It should return a path string.

Perhaps there's something off with your Emacs Unicode setup. See this article for helpful hints: https://masteringemacs.org/article/working-coding-systems-unicode-emacs

Another thing to try is: evaluate the following Elisp definition (it replaces the with <=), and restart Snail (but do not restart Emacs):

(defun julia-snail--capture-basedir (buf)
  (julia-snail--send-to-server
    :Main
    "normpath(joinpath(VERSION <= v\"0.7-\" ? JULIA_HOME : Sys.BINDIR, Base.DATAROOTDIR, \"julia\", \"base\"))"
    :repl-buf buf
    :async nil))
khyox commented 3 years ago

Thank you very much, @gcv. I totally agree, it would be better to get to the bottom of this problem. Just a quick update here. In my previous unedited comment I pointed out to Unicode since I was seeing the code instead of the symbol, but I edited it to remove that part as I thought it was an issue of the terminal messing UTF-8 and UTF-16, but it can perfectly not be a terminal problem but an issue with Emacs unicode setup, as you mention. I'll check all that! Many thanks!

khyox commented 3 years ago

Confirmed! I tried the Elisp definition and it worked. So, I followed the article that you sent me and tried again from scratch, this time all working perfectly. So all the issue was and the emacs default encoding. I guess that a way to avoid this issue in the future for other people is to force the encoding for Snail at the beginning of the source with -*- coding: utf-8 -*-? Thank you very much, @gcv, for all the kind support to get to the bottom of this problem! Closing the issue...

gcv commented 3 years ago

This is all good to know. I changed the source to use <= instead of Unicode to avoid this problem in the future, and added a link to the Unicode setup article to the documentation.