-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Hi, Thanks so much for this awsome project, it works well with all language servers along with eglot, except for python project with virtual environment in my case.
I used to manage my virual environment with https://github.com/jorgenschaefer/pyvenv, then switch to pet later.
But I've been struggled with eglot-booster-mode for a while, after I enable eglot-booster-mode with pet, eglot fails to recognize all dependencies installed in the virtual environment.
How to reproduce
- Be sure that
pyright-language-serveris installed and in your PATH - Create a virtual environment and activate it, and install a package.
python3 -m venv .venv
source .venv/bin/activate
pip install python-dotenv- Create a poc python file:
from dotenv import load_dotenv
load_dotenv() # take environment variables- Launch Emacs with following minimal
init.el
;; Initialize package sources
(require 'package)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")
("melpa" . "https://melpa.org/packages/")))
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(require 'use-package)
(use-package eglot
:ensure t
:config
(add-hook 'python-base-mode-hook 'eglot-ensure))
(use-package pet
:ensure t
:config
(add-hook 'python-base-mode-hook 'pet-mode -10))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages '(eglot-booster))
'(package-vc-selected-packages
'((eglot-booster :vc-backend Git :url "https://github.com/jdtsmith/eglot-booster"))))-
Open the
poc.pywith(eglot-booster-mode)enabled, flymake couldn't resolve thedotenvpackage

-
Reopen the
poc.pywith(eglot-booster-mode)disabled, restarteglotor restart emacs, flymake manages to resolve thedotenv
Logs
- Eglot event buffer with
eglot-booster-modeenabled:
[internal] Sat Jan 4 22:41:19 2025:
(:message "Running language server: emacs-lsp-booster --json-false-value :json-false -- /opt/homebrew/bin/pyright-langserver --stdio")
[client-request] (id:1) Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :id 1 :method "initialize" :params
(:processId 94745 :rootPath "/tmp/reproduce-bug/" :rootUri "file:///private/tmp/reproduce-bug" :initializationOptions #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data
())
:capabilities
(:workspace
(:applyEdit t :executeCommand
(:dynamicRegistration :json-false)
:workspaceEdit
(:documentChanges t)
:didChangeWatchedFiles
(:dynamicRegistration t)
:symbol
(:dynamicRegistration :json-false)
:configuration t :workspaceFolders t)
:textDocument
(:synchronization
(:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t)
:completion
(:dynamicRegistration :json-false :completionItem
(:snippetSupport :json-false :deprecatedSupport t :resolveSupport
(:properties
["documentation" "details" "additionalTextEdits"])
:tagSupport
(:valueSet
[1]))
:contextSupport t)
:hover
(:dynamicRegistration :json-false :contentFormat
["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)
:inlayHint
(:dynamicRegistration :json-false)
:publishDiagnostics
(:relatedInformation :json-false :codeDescriptionSupport :json-false :tagSupport
(:valueSet
[1 2])))
:window
(:workDoneProgress t)
:general
(:positionEncodings
["utf-32" "utf-8" "utf-16"])
:experimental #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data
()))
:workspaceFolders
[(:uri "file:///private/tmp/reproduce-bug" :name "/tmp/reproduce-bug/")]))
[stderr] [2025-01-05T06:41:19Z INFO emacs_lsp_booster::app] Running server "/opt/homebrew/bin/pyright-langserver" "--stdio"
[stderr] [2025-01-05T06:41:19Z INFO emacs_lsp_booster::app] Will convert server json to bytecode! bytecode options: BytecodeOptions { object_type: Plist, null_value: Nil, false_value: Keyword("json-false") }
[server-notification] Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:message "Pyright language server 1.1.391 starting" :type 3))
[server-notification] Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:message "Server root directory: file:///opt/homebrew/Cellar/pyright/1.1.391/libexec/lib/node_modules/pyright/dist" :type 3))
[server-notification] Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:message "Starting service instance \"/tmp/reproduce-bug/\"" :type 3))
[server-reply] (id:1) Sat Jan 4 22:41:19 2025:
(:id 1 :jsonrpc "2.0" :result
(:capabilities
(:callHierarchyProvider t :codeActionProvider
(:codeActionKinds
["quickfix" "source.organizeImports"]
:workDoneProgress t)
:completionProvider
(:completionItem
(:labelDetailsSupport t)
:resolveProvider t :triggerCharacters
["." "[" "\"" "'"]
:workDoneProgress t)
:declarationProvider
(:workDoneProgress t)
:definitionProvider
(:workDoneProgress t)
:documentHighlightProvider
(:workDoneProgress t)
:documentSymbolProvider
(:workDoneProgress t)
:executeCommandProvider
(:commands
[]
:workDoneProgress t)
:hoverProvider
(:workDoneProgress t)
:referencesProvider
(:workDoneProgress t)
:renameProvider
(:prepareProvider t :workDoneProgress t)
:signatureHelpProvider
(:triggerCharacters
["(" "," ")"]
:workDoneProgress t)
:textDocumentSync 2 :typeDefinitionProvider
(:workDoneProgress t)
:workspace
(:workspaceFolders
(:changeNotifications t :supported t))
:workspaceSymbolProvider
(:workDoneProgress t))))
[client-notification] Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :method "initialized" :params #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data
()))
[client-notification] Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :method "textDocument/didOpen" :params
(:textDocument
(:uri "file:///private/tmp/reproduce-bug/poc.py" :version 0 :languageId "python" :text "from dotenv import load_dotenv\n\nload_dotenv() # take environment variables\n")))
[client-notification] Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params
(:settings #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data
())))
[server-request] (id:0) Sat Jan 4 22:41:19 2025:
(:id 0 :jsonrpc "2.0" :method "client/registerCapability" :params
(:registrations
[(:id "d6fe5999-2c7e-4418-ad06-697614bbe76c" :method "workspace/didChangeWatchedFiles" :registerOptions
(:watchers
[(:globPattern "**/pyrightconfig.json" :kind 7)
(:globPattern "**" :kind 7)]))]))
[client-reply] (id:0) Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :id 0 :result nil)
[server-request] (id:1) Sat Jan 4 22:41:19 2025:
(:id 1 :jsonrpc "2.0" :method "workspace/configuration" :params
(:items
[(:scopeUri "file:///private/tmp/reproduce-bug" :section "python")]))
[client-reply] (id:1) Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :id 1 :result
[nil])
[server-request] (id:2) Sat Jan 4 22:41:19 2025:
(:id 2 :jsonrpc "2.0" :method "workspace/configuration" :params
(:items
[(:scopeUri "file:///private/tmp/reproduce-bug" :section "python.analysis")]))
[client-reply] (id:2) Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :id 2 :result
[nil])
[server-request] (id:3) Sat Jan 4 22:41:19 2025:
(:id 3 :jsonrpc "2.0" :method "workspace/configuration" :params
(:items
[(:scopeUri "file:///private/tmp/reproduce-bug" :section "pyright")]))
[client-reply] (id:3) Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :id 3 :result
[nil])
[server-notification] Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:message "No include entries specified; assuming /private/tmp/reproduce-bug" :type 3))
[server-notification] Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:message "Auto-excluding **/node_modules" :type 3))
[server-notification] Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:message "Auto-excluding **/__pycache__" :type 3))
[server-notification] Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:message "Auto-excluding **/.*" :type 3))
[server-notification] Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:message "Found 2 source files" :type 3))
[server-request] (id:4) Sat Jan 4 22:41:19 2025:
(:id 4 :jsonrpc "2.0" :method "client/registerCapability" :params
(:registrations
[(:id "5c6294c5-1e99-4060-906e-0d66e647288c" :method "workspace/didChangeWatchedFiles" :registerOptions
(:watchers
[(:globPattern "**/pyrightconfig.json" :kind 7)
(:globPattern "**" :kind 7)]))]))
[client-reply] (id:4) Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :id 4 :result nil)
[server-notification] Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
(:diagnostics
[(:code "reportMissingImports" :codeDescription
(:href "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportMissingImports")
:message "Import \"dotenv\" could not be resolved" :range
(:end
(:character 11 :line 0)
:start
(:character 5 :line 0))
:severity 1 :source "Pyright")]
:uri "file:///private/tmp/reproduce-bug/poc.py" :version 0))
[server-request] (id:5) Sat Jan 4 22:41:19 2025:
(:id 5 :jsonrpc "2.0" :method "client/unregisterCapability" :params
(:unregisterations
[(:id "d6fe5999-2c7e-4418-ad06-697614bbe76c" :method "workspace/didChangeWatchedFiles")]))
[client-reply] (id:5) Sat Jan 4 22:41:19 2025:
(:jsonrpc "2.0" :id 5 :result nil)
[client-request] (id:2) Sat Jan 4 22:41:35 2025:
(:jsonrpc "2.0" :id 2 :method "textDocument/signatureHelp" :params
(:textDocument
(:uri "file:///private/tmp/reproduce-bug/poc.py")
:position
(:line 0 :character 5)))
[client-request] (id:3) Sat Jan 4 22:41:35 2025:
(:jsonrpc "2.0" :id 3 :method "textDocument/hover" :params
(:textDocument
(:uri "file:///private/tmp/reproduce-bug/poc.py")
:position
(:line 0 :character 5)))
[client-request] (id:4) Sat Jan 4 22:41:35 2025:
(:jsonrpc "2.0" :id 4 :method "textDocument/documentHighlight" :params
(:textDocument
(:uri "file:///private/tmp/reproduce-bug/poc.py")
:position
(:line 0 :character 5)))
[server-reply] (id:2) Sat Jan 4 22:41:35 2025:
(:id 2 :jsonrpc "2.0" :result nil)
[server-reply] (id:3) Sat Jan 4 22:41:35 2025:
(:id 3 :jsonrpc "2.0" :result nil)
[server-reply] (id:4) Sat Jan 4 22:41:35 2025:
(:id 4 :jsonrpc "2.0" :result
[(:kind 2 :range
(:end
(:character 11 :line 0)
:start
(:character 5 :line 0)))])
- Eglot event buffer with
eglot-booster-modedisabled:
[internal] Sat Jan 4 22:43:04 2025:
(:message "Running language server: /opt/homebrew/bin/pyright-langserver --stdio")
[client-request] (id:1) Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :id 1 :method "initialize" :params
(:processId 94745 :rootPath "/tmp/reproduce-bug/" :rootUri "file:///private/tmp/reproduce-bug" :initializationOptions #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data
())
:capabilities
(:workspace
(:applyEdit t :executeCommand
(:dynamicRegistration :json-false)
:workspaceEdit
(:documentChanges t)
:didChangeWatchedFiles
(:dynamicRegistration t)
:symbol
(:dynamicRegistration :json-false)
:configuration t :workspaceFolders t)
:textDocument
(:synchronization
(:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t)
:completion
(:dynamicRegistration :json-false :completionItem
(:snippetSupport :json-false :deprecatedSupport t :resolveSupport
(:properties
["documentation" "details" "additionalTextEdits"])
:tagSupport
(:valueSet
[1]))
:contextSupport t)
:hover
(:dynamicRegistration :json-false :contentFormat
["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)
:inlayHint
(:dynamicRegistration :json-false)
:publishDiagnostics
(:relatedInformation :json-false :codeDescriptionSupport :json-false :tagSupport
(:valueSet
[1 2])))
:window
(:workDoneProgress t)
:general
(:positionEncodings
["utf-32" "utf-8" "utf-16"])
:experimental #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data
()))
:workspaceFolders
[(:uri "file:///private/tmp/reproduce-bug" :name "/tmp/reproduce-bug/")]))
[server-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:type 3 :message "Pyright language server 1.1.391 starting"))
[server-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:type 3 :message "Server root directory: file:///opt/homebrew/Cellar/pyright/1.1.391/libexec/lib/node_modules/pyright/dist"))
[server-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:type 3 :message "Starting service instance \"/tmp/reproduce-bug/\""))
[server-reply] (id:1) Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :id 1 :result
(:capabilities
(:textDocumentSync 2 :definitionProvider
(:workDoneProgress t)
:declarationProvider
(:workDoneProgress t)
:typeDefinitionProvider
(:workDoneProgress t)
:referencesProvider
(:workDoneProgress t)
:documentSymbolProvider
(:workDoneProgress t)
:workspaceSymbolProvider
(:workDoneProgress t)
:hoverProvider
(:workDoneProgress t)
:documentHighlightProvider
(:workDoneProgress t)
:renameProvider
(:prepareProvider t :workDoneProgress t)
:completionProvider
(:triggerCharacters
["." "[" "\"" "'"]
:resolveProvider t :workDoneProgress t :completionItem
(:labelDetailsSupport t))
:signatureHelpProvider
(:triggerCharacters
["(" "," ")"]
:workDoneProgress t)
:codeActionProvider
(:codeActionKinds
["quickfix" "source.organizeImports"]
:workDoneProgress t)
:executeCommandProvider
(:commands
[]
:workDoneProgress t)
:callHierarchyProvider t :workspace
(:workspaceFolders
(:supported t :changeNotifications t)))))
[client-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "initialized" :params #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data
()))
[client-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "textDocument/didOpen" :params
(:textDocument
(:uri "file:///private/tmp/reproduce-bug/poc.py" :version 0 :languageId "python" :text "from dotenv import load_dotenv\n\nload_dotenv() # take environment variables\n")))
[client-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params
(:settings
(:python
(:pythonPath "/tmp/reproduce-bug/.venv/bin/python" :venvPath "/tmp/reproduce-bug/.venv/"))))
[server-request] (id:0) Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :id 0 :method "client/registerCapability" :params
(:registrations
[(:id "b4784d21-9050-40f1-b613-49b3ef9851f6" :method "workspace/didChangeWatchedFiles" :registerOptions
(:watchers
[(:globPattern "**/pyrightconfig.json" :kind 7)
(:globPattern "**" :kind 7)]))]))
[client-reply] (id:0) Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :id 0 :result nil)
[server-request] (id:1) Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :id 1 :method "workspace/configuration" :params
(:items
[(:scopeUri "file:///private/tmp/reproduce-bug" :section "python")]))
[client-reply] (id:1) Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :id 1 :result
[(:pythonPath "/tmp/reproduce-bug/.venv/bin/python" :venvPath "/tmp/reproduce-bug/.venv/")])
[server-request] (id:2) Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :id 2 :method "workspace/configuration" :params
(:items
[(:scopeUri "file:///private/tmp/reproduce-bug" :section "python.analysis")]))
[client-reply] (id:2) Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :id 2 :result
[nil])
[server-request] (id:3) Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :id 3 :method "workspace/configuration" :params
(:items
[(:scopeUri "file:///private/tmp/reproduce-bug" :section "pyright")]))
[client-reply] (id:3) Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :id 3 :result
[nil])
[server-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:type 3 :message "Setting pythonPath for service \"/tmp/reproduce-bug/\": \"/tmp/reproduce-bug/.venv/bin/python\""))
[server-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:type 3 :message "No include entries specified; assuming /private/tmp/reproduce-bug"))
[server-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:type 3 :message "Auto-excluding **/node_modules"))
[server-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:type 3 :message "Auto-excluding **/__pycache__"))
[server-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:type 3 :message "Auto-excluding **/.*"))
[server-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:type 3 :message "Assuming Python version 3.13.1.final.0"))
[server-notification] Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:type 3 :message "Found 2 source files"))
[server-request] (id:4) Sat Jan 4 22:43:04 2025:
(:jsonrpc "2.0" :id 4 :method "client/registerCapability" :params
(:registrations
[(:id "fb09fcb6-18dc-4e28-864a-5b5cfe0fcb89" :method "workspace/didChangeWatchedFiles" :registerOptions
(:watchers
[(:globPattern "**/pyrightconfig.json" :kind 7)
(:globPattern "**" :kind 7)]))]))
[client-reply] (id:4) Sat Jan 4 22:43:05 2025:
(:jsonrpc "2.0" :id 4 :result nil)
[server-notification] Sat Jan 4 22:43:05 2025:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
(:uri "file:///private/tmp/reproduce-bug/poc.py" :version 0 :diagnostics
[]))
[server-request] (id:5) Sat Jan 4 22:43:05 2025:
(:jsonrpc "2.0" :id 5 :method "client/unregisterCapability" :params
(:unregisterations
[(:id "b4784d21-9050-40f1-b613-49b3ef9851f6" :method "workspace/didChangeWatchedFiles")]))
[client-reply] (id:5) Sat Jan 4 22:43:05 2025:
(:jsonrpc "2.0" :id 5 :result nil)
Metadata
Metadata
Assignees
Labels
No labels
