How to configure Python lsp in GNOME Builder?

Hello,

I am running Fedora 44 with GNOME 50. I installed GNOME Builder via Flatpak and created a GTK4 project with it. I wanted to format the Python file but it did not work, it failed with the error message: “No language server” connected. I checked the Builder settings, the Python lsp is activated.

Then I tried to install the lsp in various ways, but nothing worked. I thought maybe the flatpak version does not have the permissions on the file system so I installed Builder from the rpm repos, but I still get the same error message.

How do you configure the Python lsp in Builder? I am out of ideas…

Thanks

Hi,

Does that help?

Hey,

thanks for your reply. I found both threads before I posted and I tried them but both do not work.

According to Builder’s README it should just work if it’s installed:

Builder comes with support for a number of language servers builtin. It automatically locates the language server within your build environment and runs it there (possibly in a container). If it can find it elsewhere (such as on the host) that will be used as a fallback.

But so far it does not and I am not sure why.

Can you try running Builder in verbose mode?

gnome-builder -vvv

and check if there are any suspicious logs?

It’s interesting…

~$ LANG=en_GB gnome-builder -vvv
17:20:51.6020                                      main[ 17586]:  MESSAGE: GNOME Builder 50.0 (50.0) from channel "other" starting with ABI 50
17:20:51.6021                                      main[ 17586]:  MESSAGE: Initializing with GNOME desktop and GTK+ 4.22.5.
[...]
17:20:51.7248                                      ruff[ 17586]:    DEBUG: Registered type ruff+IdeLspPluginService
17:20:51.7248                   ide-application-plugins[ 17586]:    DEBUG: Loaded plugin "ruff" with module-dir "resource:///plugins/ruff/"
[...]
17:20:51.7254                     pylsp-language-server[ 17586]:    DEBUG: Registered type pylsp-language-server+IdeLspPluginService
17:20:51.7254                   ide-application-plugins[ 17586]:    DEBUG: Loaded plugin "pylsp-language-server" with module-dir "resource:///plugins/pylsp-language-server/"
[...]
17:20:51.7293                   ide-application-plugins[ 17586]:    DEBUG: Loaded plugin "flake8" with module-dir "resource:///plugins/flake8/"
[...]
17:20:53.8917                      ide-runtime-provider[ 17586]:    DEBUG: Discovered runtime “host”
[...]
17:20:58.3369                           ide-lsp-service[ 17586]:    DEBUG: Pipeline changed, requesting LSP service ruff+IdeLspPluginService restart
17:20:58.3369                           ide-lsp-service[ 17586]:    DEBUG: Request to restart LSP service ruff+IdeLspPluginService
17:20:58.3373                           ide-lsp-service[ 17586]:    DEBUG: Pipeline changed, requesting LSP service ruff+IdeLspPluginService restart
17:20:58.3373                           ide-lsp-service[ 17586]:    DEBUG: Request to restart LSP service ruff+IdeLspPluginService
17:20:58.3375                           ide-lsp-service[ 17586]:    DEBUG: Pipeline changed, requesting LSP service ruff+IdeLspPluginService restart
17:20:58.3376                           ide-lsp-service[ 17586]:    DEBUG: Request to restart LSP service ruff+IdeLspPluginService
17:20:58.3391                           ide-lsp-service[ 17586]:    DEBUG: Pipeline changed, requesting LSP service ruff+IdeLspPluginService restart
17:20:58.3392                           ide-lsp-service[ 17586]:    DEBUG: Request to restart LSP service ruff+IdeLspPluginService
17:20:58.3393                           ide-lsp-service[ 17586]:    DEBUG: Pipeline changed, requesting LSP service pylsp-language-server+IdeLspPluginService restart
17:20:58.3393                           ide-lsp-service[ 17586]:    DEBUG: Request to restart LSP service pylsp-language-server+IdeLspPluginService
17:20:58.3394                               ide-runtime[ 17586]:    DEBUG: Preparing run context for build using non-native runtime. "host" instead of "flatpak:org.gnome.Platform/x86_64/50".
17:20:58.3395                   ide-subprocess-launcher[ 17586]:    DEBUG: Launching /bin/bash -l -c 'pylsp' [env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus DESKTOP_SESSION=gnome DISPLAY=:0 LANG=en_GB HOME=/home/apollo SHELL=/bin/bash SSH_AUTH_SOCK=/run/user/1000/gcr/ssh USER=apollo WAYLAND_DISPLAY=wayland-0 XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.E5AUW3 XDG_CURRENT_DESKTOP=GNOME XDG_MENU_PREFIX=gnome- XDG_SESSION_DESKTOP=gnome XDG_SESSION_TYPE=wayland TERM=xterm-256color COLORTERM=truecolor] [directory /home/apollo/src/loom] inheriting parent environment
17:20:58.3480                  ide-subproces-supervisor[ 17586]:    DEBUG: Setting subprocess to 17923
17:20:58.3488                           ide-lsp-service[ 17586]:  MESSAGE: Language server “pylsp” spawned as process 17923
17:20:58.3516                           ide-lsp-service[ 17586]:    DEBUG: Pipeline changed, requesting LSP service ruff+IdeLspPluginService restart
17:20:58.3516                           ide-lsp-service[ 17586]:    DEBUG: Request to restart LSP service ruff+IdeLspPluginService
17:20:58.3726                    ide-source-view-addins[ 17586]:    DEBUG: Adding completion provider GbpWordCompletionProvider from module words
17:20:58.3727                    ide-source-view-addins[ 17586]:    DEBUG: Adding completion provider GbpTopMatchCompletionProvider from module top-match
17:20:58.3728                    ide-source-view-addins[ 17586]:    DEBUG: Adding completion provider GbpSnippetCompletionProvider from module snippets
17:20:58.3728                    ide-source-view-addins[ 17586]:    DEBUG: Adding completion provider ruff+CompletionProvider from module ruff
17:20:58.3728                    ide-source-view-addins[ 17586]:    DEBUG: Adding completion provider pylsp-language-server+CompletionProvider from module pylsp-language-server
17:20:58.3728                    ide-source-view-addins[ 17586]:    DEBUG: Adding completion provider GbpPygiCompletionProvider from module pygi
17:20:58.3728                    ide-source-view-addins[ 17586]:    DEBUG: Adding completion provider IdeCtagsCompletionProvider from module ctags
17:20:58.3736                    ide-source-view-addins[ 17586]:    DEBUG: Adding hover provider GbpSymbolHoverProvider from module symbol-tree
17:20:58.3739                    ide-source-view-addins[ 17586]:    DEBUG: Adding hover provider ruff+HoverProvider from module ruff
17:20:58.3739                    ide-source-view-addins[ 17586]:    DEBUG: Adding hover provider pylsp-language-server+HoverProvider from module pylsp-language-server
[...]
17:20:58.3850                           ide-editor-page[ 17586]:    DEBUG: Keyboard focus entered page "src/main.py"
17:20:58.6520                               ide-runtime[ 17586]:    DEBUG: Preparing run context for build using non-native runtime. "host" instead of "flatpak:org.gnome.Platform/x86_64/50".
17:20:58.6521                   ide-subprocess-launcher[ 17586]:    DEBUG: Launching /bin/bash -l -c 'flake8' '--format=default' '-' [env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus DESKTOP_SESSION=gnome DISPLAY=:0 LANG=en_GB HOME=/home/apollo SHELL=/bin/bash SSH_AUTH_SOCK=/run/user/1000/gcr/ssh USER=apollo WAYLAND_DISPLAY=wayland-0 XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.E5AUW3 XDG_CURRENT_DESKTOP=GNOME XDG_MENU_PREFIX=gnome- XDG_SESSION_DESKTOP=gnome XDG_SESSION_TYPE=wayland TERM=xterm-256color COLORTERM=truecolor] [directory /home/apollo/src/loom] inheriting parent environment
17:20:59.2216                           ide-lsp-service[ 17586]:    DEBUG: Pipeline changed, requesting LSP service ruff+IdeLspPluginService restart
17:20:59.2217                           ide-lsp-service[ 17586]:    DEBUG: Request to restart LSP service ruff+IdeLspPluginService
17:20:59.2222                             GtkSourceView[ 17586]:    DEBUG: No client to deliver request population failed
17:20:59.6320                               ide-runtime[ 17586]:    DEBUG: Preparing run context for build using non-native runtime. "host" instead of "flatpak:org.gnome.Platform/x86_64/50".
17:20:59.6320                   ide-subprocess-launcher[ 17586]:    DEBUG: Launching /bin/bash -l -c 'flake8' '--format=default' '-' [env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus DESKTOP_SESSION=gnome DISPLAY=:0 LANG=en_GB HOME=/home/apollo SHELL=/bin/bash SSH_AUTH_SOCK=/run/user/1000/gcr/ssh USER=apollo WAYLAND_DISPLAY=wayland-0 XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.E5AUW3 XDG_CURRENT_DESKTOP=GNOME XDG_MENU_PREFIX=gnome- XDG_SESSION_DESKTOP=gnome XDG_SESSION_TYPE=wayland TERM=xterm-256color COLORTERM=truecolor] [directory /home/apollo/src/loom] inheriting parent environment
17:21:00.6357                               ide-runtime[ 17586]:    DEBUG: Preparing run context for build using non-native runtime. "host" instead of "flatpak:org.gnome.Platform/x86_64/50".
17:21:00.6358                   ide-subprocess-launcher[ 17586]:    DEBUG: Launching /bin/bash -l -c 'flake8' '--format=default' '-' [env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus DESKTOP_SESSION=gnome DISPLAY=:0 LANG=en_GB HOME=/home/apollo SHELL=/bin/bash SSH_AUTH_SOCK=/run/user/1000/gcr/ssh USER=apollo WAYLAND_DISPLAY=wayland-0 XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.E5AUW3 XDG_CURRENT_DESKTOP=GNOME XDG_MENU_PREFIX=gnome- XDG_SESSION_DESKTOP=gnome XDG_SESSION_TYPE=wayland TERM=xterm-256color COLORTERM=truecolor] [directory /home/apollo/src/loom] inheriting parent environment
17:21:01.9548                               ide-runtime[ 17586]:    DEBUG: Preparing run context for build using non-native runtime. "host" instead of "flatpak:org.gnome.Platform/x86_64/50".
17:21:01.9549                   ide-subprocess-launcher[ 17586]:    DEBUG: Launching /bin/bash -l -c 'flake8' '--format=default' '-' [env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus DESKTOP_SESSION=gnome DISPLAY=:0 LANG=en_GB HOME=/home/apollo SHELL=/bin/bash SSH_AUTH_SOCK=/run/user/1000/gcr/ssh USER=apollo WAYLAND_DISPLAY=wayland-0 XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.E5AUW3 XDG_CURRENT_DESKTOP=GNOME XDG_MENU_PREFIX=gnome- XDG_SESSION_DESKTOP=gnome XDG_SESSION_TYPE=wayland TERM=xterm-256color COLORTERM=truecolor] [directory /home/apollo/src/loom] inheriting parent environment
17:21:01.9651                             ide-formatter[ 17586]:    DEBUG: Formatting document "src/main.py" using ruff+Formatter
[...]
17:21:06.1424                    ide-source-view-addins[ 17586]:    DEBUG: Removing completion provider ruff+CompletionProvider from module ruff
17:21:06.1424                    ide-source-view-addins[ 17586]:    DEBUG: Removing completion provider GbpWordCompletionProvider from module words
17:21:06.1424                    ide-source-view-addins[ 17586]:    DEBUG: Removing completion provider GbpTopMatchCompletionProvider from module top-match
17:21:06.1424                    ide-source-view-addins[ 17586]:    DEBUG: Removing completion provider pylsp-language-server+CompletionProvider from module pylsp-language-server
17:21:06.1424                    ide-source-view-addins[ 17586]:    DEBUG: Removing completion provider GbpPygiCompletionProvider from module pygi
17:21:06.1424                    ide-source-view-addins[ 17586]:    DEBUG: Removing completion provider IdeCtagsCompletionProvider from module ctags
17:21:06.1425                    ide-source-view-addins[ 17586]:    DEBUG: Removing hover provider GbpCodeuiHoverProvider from module codeui
17:21:06.1425                    ide-source-view-addins[ 17586]:    DEBUG: Removing hover provider ruff+HoverProvider from module ruff
17:21:06.1425                    ide-source-view-addins[ 17586]:    DEBUG: Removing hover provider pylsp-language-server+HoverProvider from module pylsp-language-server
[...]
17:21:06.1448                           ide-lsp-service[ 17586]:    DEBUG: Stopping LSP client pylsp-language-server+IdeLspPluginService
17:21:06.1449                            ide-subprocess[ 17586]:    DEBUG: Force exit on subprocess 17923

According to the logs it spawned pylsp and it also says it tried to run a formatter but inside GNOME Builder nothing happens. :thinking:

That looks suspicious…

I’ll give a try on my side and compare the debug output.

Code completion works on my side, here some filtered logs:

16:18:18.3377                           ide-lsp-service[ 71273]:    DEBUG: Pipeline changed, requesting LSP service ruff+IdeLspPluginService restart
16:18:18.3377                           ide-lsp-service[ 71273]:    DEBUG: Request to restart LSP service ruff+IdeLspPluginService
16:18:18.3379                           ide-lsp-service[ 71273]:    DEBUG: Pipeline changed, requesting LSP service ruff+IdeLspPluginService restart
16:18:18.3379                           ide-lsp-service[ 71273]:    DEBUG: Request to restart LSP service ruff+IdeLspPluginService
16:18:18.3380                           ide-lsp-service[ 71273]:    DEBUG: Pipeline changed, requesting LSP service ruff+IdeLspPluginService restart
16:18:18.3380                           ide-lsp-service[ 71273]:    DEBUG: Request to restart LSP service ruff+IdeLspPluginService
16:18:18.3385                           ide-lsp-service[ 71273]:    DEBUG: Pipeline changed, requesting LSP service ruff+IdeLspPluginService restart
16:18:18.3385                           ide-lsp-service[ 71273]:    DEBUG: Request to restart LSP service ruff+IdeLspPluginService
16:18:18.3386                           ide-lsp-service[ 71273]:    DEBUG: Pipeline changed, requesting LSP service pylsp-language-server+IdeLspPluginService restart
16:18:18.3386                           ide-lsp-service[ 71273]:    DEBUG: Request to restart LSP service pylsp-language-server+IdeLspPluginService
16:18:18.3386                               ide-runtime[ 71273]:    DEBUG: Preparing run context for build using non-native runtime. "host" instead of "flatpak:org.gnome.Platform/x86_64/51".
16:18:18.3387                   ide-subprocess-launcher[ 71273]:    DEBUG: Launching /bin/bash -l -c '/bin/sh' '-c' '. '\''/var/projects/.gnome-builder/projects/galaxyconquest/builds/org.gnome.gitlab.gwillems.galaxyconquest.json-flatpak-org.gnome.Platform-51-x86_64-main/.gnome-builder-devenv'\''
16:18:18.3472                  ide-subproces-supervisor[ 71273]:    DEBUG: Setting subprocess to 72341
16:18:18.3485                           ide-lsp-service[ 71273]:  MESSAGE: Language server “pylsp” spawned as process 72341
16:18:18.3492                           ide-lsp-service[ 71273]:    DEBUG: Pipeline changed, requesting LSP service ruff+IdeLspPluginService restart
16:18:18.3492                           ide-lsp-service[ 71273]:    DEBUG: Request to restart LSP service ruff+IdeLspPluginService
16:18:18.3588                    ide-source-view-addins[ 71273]:    DEBUG: Adding completion provider GbpWordCompletionProvider from module words
16:18:18.3589                    ide-source-view-addins[ 71273]:    DEBUG: Adding completion provider GbpTopMatchCompletionProvider from module top-match
16:18:18.3589                    ide-source-view-addins[ 71273]:    DEBUG: Adding completion provider GbpSnippetCompletionProvider from module snippets
16:18:18.3589                    ide-source-view-addins[ 71273]:    DEBUG: Adding completion provider ruff+CompletionProvider from module ruff
16:18:18.3589                    ide-source-view-addins[ 71273]:    DEBUG: Adding completion provider pylsp-language-server+CompletionProvider from module pylsp-language-server
16:18:18.3589                    ide-source-view-addins[ 71273]:    DEBUG: Adding completion provider GbpPygiCompletionProvider from module pygi
16:18:18.3589                    ide-source-view-addins[ 71273]:    DEBUG: Adding completion provider IdeCtagsCompletionProvider from module ctags
16:18:18.3592                    ide-source-view-addins[ 71273]:    DEBUG: Adding hover provider GbpSymbolHoverProvider from module symbol-tree
16:18:18.3594                    ide-source-view-addins[ 71273]:    DEBUG: Adding hover provider ruff+HoverProvider from module ruff
16:18:18.3594                    ide-source-view-addins[ 71273]:    DEBUG: Adding hover provider pylsp-language-server+HoverProvider from module pylsp-language-server
16:18:18.3594                    ide-source-view-addins[ 71273]:    DEBUG: Adding hover provider GbpCodeuiHoverProvider from module codeui
16:18:18.3594                    ide-source-view-addins[ 71273]:    DEBUG: Adding hover provider IdeDebuggerHoverProvider from module debuggerui
16:18:18.3626                             ide-workspace[ 71273]:    DEBUG: Adding IdeEditorPage to page MRU
16:18:18.3680                           ide-editor-page[ 71273]:    DEBUG: Keyboard focus entered page "galaxyconquest/ui/sector.py"
16:18:23.7392                           ide-lsp-service[ 71273]:    DEBUG: Pipeline changed, requesting LSP service ruff+IdeLspPluginService restart
16:18:23.7392                           ide-lsp-service[ 71273]:    DEBUG: Request to restart LSP service ruff+IdeLspPluginService
16:18:24.5693               ide-lsp-completion-provider[ 71273]:    DEBUG: pylsp-language-server+CompletionProvider populated initial result set of 203 items
16:18:26.1369               ide-lsp-completion-provider[ 71273]:    DEBUG: pylsp-language-server+CompletionProvider populated initial result set of 32 items
16:18:32.4238                             GtkSourceView[ 71273]:    DEBUG: No more tab stops, moving to end of snippet
16:18:39.3611               ide-lsp-completion-provider[ 71273]:    DEBUG: pylsp-language-server+CompletionProvider populated initial result set of 32 items
16:18:42.9742                             ide-workspace[ 71273]:    DEBUG: Removing IdeEditorPage from page MRU

Hmm… Strange… Thanks for testing. I think I’ll test it when I’ve got some time in a clean virtual machine. Currently it works in VSCodium so far. Not perfect, but it works.