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

Error when buffer is not visiting a file #824

Open
akash-akya opened this issue Jan 25, 2022 · 1 comment
Open

Error when buffer is not visiting a file #824

akash-akya opened this issue Jan 25, 2022 · 1 comment

Comments

@akash-akya
Copy link
Contributor

akash-akya commented Jan 25, 2022

  • Server used: ElixirLS
  • Emacs version: GNU Emacs 29.0.50
  • Operating system: mac osx
  • Eglot version: 57779f9
  • Eglot installation method: git
  • Using Doom: No

ElixisLS - M-x eglot-events-buffer

[internal] Tue Jan 25 22:22:26 2022:
(:message "Running language server: (/Users/akash/elixir-ls/language_server.sh)")
[client-request] (id:1) Tue Jan 25 22:22:26 2022:
(:jsonrpc "2.0" :id 1 :method "initialize" :params
          (:processId 17933 :rootPath "/Users/akash/rhea/" :rootUri "file:///Users/akash/rhea" :initializationOptions #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
                                                                                                                                                                ())
                      :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 t :deprecatedSupport t :tagSupport
                                                               (:valueSet
                                                                [1]))
                                              :contextSupport t)
                        :hover
                        (:dynamicRegistration :json-false :contentFormat
                                              ["markdown" "plaintext"])
                        :signatureHelp
                        (:dynamicRegistration :json-false :signatureInformation
                                              (:parameterInformation
                                               (:labelOffsetSupport t)
                                               :activeParameterSupport t))
                        :references
                        (:dynamicRegistration :json-false)
                        :definition
                        (:dynamicRegistration :json-false :linkSupport t)
                        :declaration
                        (:dynamicRegistration :json-false :linkSupport t)
                        :implementation
                        (:dynamicRegistration :json-false :linkSupport t)
                        :typeDefinition
                        (:dynamicRegistration :json-false :linkSupport t)
                        :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"]))
                                              :isPreferredSupport t)
                        :formatting
                        (:dynamicRegistration :json-false)
                        :rangeFormatting
                        (:dynamicRegistration :json-false)
                        :rename
                        (:dynamicRegistration :json-false)
                        :publishDiagnostics
                        (:relatedInformation :json-false :codeDescriptionSupport :json-false :tagSupport
                                             (:valueSet
                                              [1 2])))
                       :experimental #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
                                                   ()))))
[server-notification] Tue Jan 25 22:22:27 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "Started ElixirLS v0.8.0" :type 4))
[server-notification] Tue Jan 25 22:22:27 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "Elixir version: \"1.10.3 (compiled with Erlang/OTP 22)\"" :type 4))
[server-notification] Tue Jan 25 22:22:27 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "Erlang version: \"22\"" :type 4))
[server-notification] Tue Jan 25 22:22:27 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "ElixirLS compiled with Elixir 1.10.4 and erlang 22" :type 4))
[server-reply] (id:1) Tue Jan 25 22:22:29 2022:
(:id 1 :jsonrpc "2.0" :result
     (:capabilities
      (:codeLensProvider
       (:resolveProvider :json-false)
       :completionProvider
       (:triggerCharacters
        ["." "@" "&" "%" "^" ":" "!"])
       :definitionProvider t :documentFormattingProvider t :documentOnTypeFormattingProvider
       (:firstTriggerCharacter "\n")
       :documentSymbolProvider t :executeCommandProvider
       (:commands
        ["spec:8omSLucKATj1Li6RxRD7H21t6y_QdG0A" "expandMacro:8omSLucKATj1Li6RxRD7H21t6y_QdG0A" "manipulatePipes:8omSLucKATj1Li6RxRD7H21t6y_QdG0A"])
       :foldingRangeProvider t :hoverProvider t :implementationProvider t :macroExpansion t :referencesProvider t :signatureHelpProvider
       (:triggerCharacters
        ["(" ","])
       :textDocumentSync
       (:change 2 :openClose t :save
                (:includeText t))
       :workspace
       (:workspaceFolders
        (:changeNotifications :json-false :supported :json-false))
       :workspaceSymbolProvider t)
      :serverInfo
      (:name "ElixirLS" :version "0.8.0")))
[client-notification] Tue Jan 25 22:22:29 2022:
(:jsonrpc "2.0" :method "initialized" :params #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
                                                            ()))
[client-notification] Tue Jan 25 22:22:29 2022:
(:jsonrpc "2.0" :method "textDocument/didOpen" :params
          (:textDocument
           (:uri "file:///Users/akash/rhea/apps/pegasus/test/workers/horme/mission_timeout_worker_generator_test.exs" :version 0 :languageId "elixir" :text "<REDUCTED>")))
[client-notification] Tue Jan 25 22:22:29 2022:
(:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params
          (:settings
           (:elixirLS
            ((dialyzerEnabled . :json-false)))))
[server-notification] Tue Jan 25 22:22:29 2022:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
          (:diagnostics
           []
           :uri "file:///Users/akash/rhea/apps/pegasus/test/workers/horme/mission_timeout_worker_generator_test.exs"))
[server-notification] Tue Jan 25 22:22:29 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "MIX_ENV: test" :type 4))
[server-notification] Tue Jan 25 22:22:29 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "MIX_TARGET: host" :type 4))
[client-request] (id:2) Tue Jan 25 22:22:29 2022:
(:jsonrpc "2.0" :id 2 :method "textDocument/signatureHelp" :params
          (:textDocument
           (:uri "file:///Users/akash/rhea/apps/pegasus/test/workers/horme/mission_timeout_worker_generator_test.exs")
           :position
           (:line 0 :character 39)))
[client-request] (id:3) Tue Jan 25 22:22:29 2022:
(:jsonrpc "2.0" :id 3 :method "textDocument/hover" :params
          (:textDocument
           (:uri "file:///Users/akash/rhea/apps/pegasus/test/workers/horme/mission_timeout_worker_generator_test.exs")
           :position
           (:line 0 :character 39)))
[server-reply] (id:3) Tue Jan 25 22:22:29 2022:
(:id 3 :jsonrpc "2.0" :result
     (:contents
      []
      :range
      (:end
       (:character 43 :line 0)
       :start
       (:character 10 :line 0))))
[server-reply] (id:2) Tue Jan 25 22:22:29 2022:
(:id 2 :jsonrpc "2.0" :result
     (:activeParameter 0 :activeSignature 0 :signatures
                       [(:documentation
                         (:kind "markdown" :value "Defines a module given by name with the given contents.")
                         :label "defmodule(alias, do_block)" :parameters
                         [(:label "alias")
                          (:label "do_block")])]))
[server-notification] Tue Jan 25 22:22:43 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "Compile took 14652 milliseconds" :type 3))
[server-notification] Tue Jan 25 22:22:43 2022:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
          (:diagnostics
           [(:message "NewRelic.create_distributed_trace_payload/1 is deprecated. Use distributed_trace_headers/1 instead" :range
                      (:end
                       (:character 0 :line 33)
                       :start
                       (:character 0 :line 33))
                      :severity 2 :source "Elixir")]
           :uri "file:///Users/akash/rhea/apps/core/lib/core/http.ex"))
[server-notification] Tue Jan 25 22:22:43 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "[ElixirLS WorkspaceSymbols] Indexing..." :type 3))
[server-notification] Tue Jan 25 22:22:45 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "[ElixirLS WorkspaceSymbols] Module discovery complete" :type 3))
[server-notification] Tue Jan 25 22:22:46 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "[ElixirLS WorkspaceSymbols] 20 callbacks added to index" :type 3))
[server-notification] Tue Jan 25 22:22:51 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "[ElixirLS WorkspaceSymbols] 263 modules added to index" :type 3))
[server-notification] Tue Jan 25 22:22:54 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "[ElixirLS WorkspaceSymbols] 347 types added to index" :type 3))
[server-notification] Tue Jan 25 22:23:02 2022:
(:jsonrpc "2.0" :method "window/logMessage" :params
          (:message "[ElixirLS WorkspaceSymbols] 4570 functions added to index" :type 3))
[client-notification] Tue Jan 25 22:23:18 2022:
(:jsonrpc "2.0" :method "textDocument/didOpen" :params
          (:textDocument
           (:uri "file:///Users/akash/rhea/apps/horme/lib/horme/api/merchants_controller.ex" :version 0 :languageId "elixir" :text "<REDUCTED>")))
[server-notification] Tue Jan 25 22:23:18 2022:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
          (:diagnostics
           []
           :uri "file:///Users/akash/rhea/apps/horme/lib/horme/api/merchants_controller.ex"))

Backtrace (mandatory, unless no error message seen or heard):

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
  file-truename(nil)
  eglot--path-to-uri(nil)
  eglot--TextDocumentIdentifier()
  eglot--TextDocumentPositionParams()
  eglot-signature-eldoc-function(#f(compiled-function (string &rest plist) #<bytecode 0xef14d65941d95da>))
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_19>(eglot-signature-eldoc-function)
  eldoc-documentation-enthusiast()
  eldoc--invoke-strategy(nil)
  eldoc-print-current-symbol-info()
  #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_14>()
  apply(#<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_14> nil)
  timer-event-handler([t 0 0 500000 nil #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_14> nil idle 0 nil])

Minimal configuration (mandatory)

;; Example of a minimal configuration
(setq package-enable-at-startup nil
      package-archives
      '(("melpa" . "http://melpa.milkbox.net/packages/")
        ("gnu" . "http://elpa.gnu.org/packages/")))

(require 'package)
(package-initialize)

(package-install 'eglot)
(package-install 'elixir-mode)
(package-install 'magit)

(add-to-list 'eglot-server-programs `(elixir-mode . ("/Users/akash/elixir-ls/language_server.sh")))

Steps to reproduce

I think the issue is not specific to any language server, so should be possible to reproduce with any git repo. But mentioning the steps for the sake of completeness

  • clone and open any elixir git repo
  • M-x toggle-debug-on-error
  • create an elixir-mode non-visiting-buffer. By opening any file in different revision from magit stash, diff, log etc
  • move cursor around to trigger textDocument/signatureHelp

Issue is related to #116. There is a fix for indirect-buffer a1f2033. But in this case this seems to be just a buffer without visiting file.

@joaotavora joaotavora added the bug label Apr 4, 2022
@joaotavora
Copy link
Owner

I think this is an Eglot bug, but I don't have a good idea for solving it. it never happens to me when I use VC, for example (I don't use Magit). That's because VC uses an actual file to backup the foo-mode buffers it creates.

LSP requires URIs for things. Should we just make up an URI?

Also I can't find the part in your LSP transcript where the textDocument/signatureHelp is issued. I'm looking for the URI of the file-less buffer thing that it presumably invoked didOpen on.

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

Successfully merging a pull request may close this issue.

2 participants