non-Jedi / eglot-jl

Wrapper for using Julia LanguageServer.jl with emacs eglot
Creative Commons Zero v1.0 Universal
62 stars 11 forks source link

eglot-jl and Manifest.toml #10

Closed mgr327 closed 4 years ago

mgr327 commented 4 years ago

Every time I try to 'M-x eglot' when in a folder that has the file Manifest.toml, I get the message 'error in process sentinel: [eglot] -1: Server died'. Just to clarify, renaming the file, e.g. to Manifest.toml.bak, allows eglot-jl to run normally. Any ideas what (I am doing) wrong?

The content of the buffers that may be relevant:


Messages [jsonrpc] Server exited with status 1 error in process sentinel: eglot--error: [eglot] -1: Server died error in process sentinel: [eglot] -1: Server died


EGLOT .... events

[stderr] Stacktrace: [stderr] Stacktrace: [stderr] nil [stderr] nil [stderr] nil [stderr] nil [stderr] [1] require(::Module, ::Symbol) at ./loading.jl:892 [stderr] [2] include(::Module, ::String) at ./Base.jl:377 [stderr] [3] exec_options(::Base.JLOptions) at ./client.jl:288 [stderr] [4] _start() at ./client.jl:484 [stderr] in expression starting at /home/mgr/.emacs.d/elpa/eglot-jl-20200508.1552/eglot-jl.jl:5 [internal] Wed May 13 15:09:24 2020: (:message "Connection state changed" :change "exited abnormally with code 1\n")

----------b---y---e---b---y---e---------- [stderr] [stderr] [stderr] nil [stderr] nil [stderr] Process EGLOT (clustering/julia-mode) stderr finished

non-Jedi commented 4 years ago

Could you please post the full contents of M-x eglot-events-buffer in backticks? You can put it in a gist if it's too long. What you've posted above looks to be truncated to me, but it's hard to tell.

This is erroring on import Pkg which makes me think the LOAD_PATH manipulation eglot-jl.jl does might not work correctly on all platforms. What OS is this on, and how are emacs and julia installed?

mgr327 commented 4 years ago

(a) The full content of M-x eglot-events-buffer is below. My apologies - I didn't realize I am posting a truncated buffer

(b) I have the same problem on two different machines - one is Fedora 32, emacs 26.3 from the system, Julia 1.4.1 from nalimilan/julia Copr build (https://copr.fedorainfracloud.org/coprs/nalimilan/julia/); another is Debian 10.4 Chromebook Linix, emacs 26.1 from the system, Julia 1.4.1, generic Linux binaries from julialang. Neither OS/Julia/Emacs combinations ever gave me any problems.

The eglot-events-buffer is from the chromebook.

[client-request] (id:1) Wed May 13 16:35:49 2020:
(:jsonrpc "2.0" :id 1 :method "initialize" :params
      (:processId 9524 :rootPath "/home/mgr/clustering/" :rootUri "file:///home/mgr/clustering/" :initializationOptions nil :capabilities
              (:workspace
               (:applyEdit t :executeCommand
                   (:dynamicRegistration :json-false)
                   :workspaceEdit
                   (:documentChanges :json-false)
                   :didChangeWatchedFiles
                   (:dynamicRegistration t)
                   :symbol
                   (:dynamicRegistration :json-false)
                   :configuration t)
               :textDocument
               (:synchronization
            (:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t)
            :completion
            (:dynamicRegistration :json-false :completionItem
                          (:snippetSupport :json-false)
                          :contextSupport t)
            :hover
            (:dynamicRegistration :json-false :contentFormat
                          ["plaintext"])
            :signatureHelp
            (:dynamicRegistration :json-false :signatureInformation
                          (:parameterInformation
                           (:labelOffsetSupport t)))
            :references
            (:dynamicRegistration :json-false)
            :definition
            (:dynamicRegistration :json-false)
            :declaration
            (:dynamicRegistration :json-false)
            :implementation
            (:dynamicRegistration :json-false)
            :typeDefinition
            (:dynamicRegistration :json-false)
            :documentSymbol
            (:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t :symbolKind
                          (:valueSet
                           [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26]))
            :documentHighlight
            (:dynamicRegistration :json-false)
            :codeAction
            (:dynamicRegistration :json-false :codeActionLiteralSupport
                          (:codeActionKind
                           (:valueSet
                        ["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"])))
            :formatting
            (:dynamicRegistration :json-false)
            :rangeFormatting
            (:dynamicRegistration :json-false)
            :rename
            (:dynamicRegistration :json-false)
            :publishDiagnostics
            (:relatedInformation :json-false))
               :experimental nil)))
[stderr] nil
[stderr]  Activating environment at `~/clustering/Project.toml`
[stderr] nil
[stderr] nil
[stderr] ERROR: LoadError: ArgumentError: Package Pkg not found in current path:
[stderr] - Run `import Pkg; Pkg.add("Pkg")` to install the Pkg package.
[stderr] 
[stderr] 
[stderr] Stacktrace:
[stderr] Stacktrace:
[stderr] nil
[stderr] nil
[stderr] nil
[stderr] nil
[stderr]  [1] require(::Module, ::Symbol) at ./loading.jl:892
[stderr]  [2] include(::Module, ::String) at ./Base.jl:377
[stderr]  [3] exec_options(::Base.JLOptions) at ./client.jl:288
[stderr]  [4] _start() at ./client.jl:484
[stderr] in expression starting at /home/mgr/.emacs.d/elpa/eglot-jl-20200508.1552/eglot-jl.jl:5
[internal] Wed May 13 16:35:51 2020:
(:message "Connection state changed" :change "exited abnormally with code 1\n")

----------b---y---e---b---y---e----------
[stderr] 
[stderr] 
[stderr] nil
[stderr] nil
[stderr] Process EGLOT (clustering/julia-mode) stderr finished
non-Jedi commented 4 years ago

I really don't understand how this is happening unless you have an environment variable that changes DEPOT_PATH or overrides the --project flag. You haven't set JULIA_PROJECT, JULIA_LOAD_PATH, or JULIA_DEPOT_PATH have you? To make sure could you please start a julia REPL in an emacs shell and post what LOAD_PATH, DEPOT_PATH, and using Pkg; pkg"status" show?

non-Jedi commented 4 years ago

The problem is that eglot-jl.jl is somehow being called with the equivalent of --project=~/clustering/Project.toml instead of --project=/path/to/eglot-jl/. Did you override eglot-jl-base by any chance? Or maybe load-file-name doesn't work how I think it does.

ffevotte commented 4 years ago

Or did you maybe customize eglot-jl-julia-flags?

mgr327 commented 4 years ago

OK, thank you. I think the mystery is solved:

I do have the following lines in my julia startup file:

if isfile("Project.toml") && isfile("Manifest.toml")
    Pkg.activate(".")
end 

Apparently they are messing up the magic of eglot-jl ...

The solution for me is to define eglot-jl-julia-flags to be -startup-file=no" instead of nil . After that change, everything works as expected.

You probably should consider that -startup-file=no" be the default value for eglot-jl-julia-flags ...

I'll close this issue tomorrow unless I hear from you otherwise.

non-Jedi commented 4 years ago

I thought the startup-file only got run in interactive mode. Guess not. Making --startup-file=no a default element of eglot-jl-julia-flags is probably the right way forward. Thanks for the bug report.