Fix basedpyright install failure on Debian #7

Merged
branderson merged 1 commits from nvim-basedpyright-venv into master 2026-08-17 14:42:56 -07:00
Collaborator

Summary generated by LLM agent

Fixes the [mason-lspconfig.nvim] failed to install basedpyright error that appears on every nvim startup in the dejima container.

Cause

mason installs basedpyright from PyPI, which means creating a venv for it first (mason-core/installer/managers/pypi.lua). Debian ships venv's ensurepip in a separate python3-venv package rather than with python3 itself, and the container image doesn't have it, so python3 -m venv exits 1:

$ python3 -m venv /tmp/vtest
The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package [...]
exit=1

which matches the mason log exactly:

Installation failed for Package(name=basedpyright) error=spawn: python3 failed with exit code 1 and signal 0.

ruff installs fine alongside it because mason pulls that one as a prebuilt binary from a GitHub release, not from PyPI, so it never touches a venv. The Provider "pypi" "get_supported_python_versions" failed: wget failed with exit code 4 line just above it in the log is a separate, transient startup race: pypi.org, files.pythonhosted.org and api.github.com are all reachable from the container, and that provider call failing only means mason skips the Python version compatibility check, it does not fail the install.

Changes

packages/apt.global gains python3-venv, which is the actual fix. Arch already bundles ensurepip with its python package, and brew.global installs a full python, so this only affects the Debian path.

config/nvim/lua/plugins/lsp.lua now checks for venv support before adding basedpyright to ensure_installed, mirroring the has_public_npm() guard already there for the npm-sourced servers. On a machine that lacks it the user gets one warning naming the package to install, instead of a failed install on every startup. ruff is unconditional now that it is separated out, since it has no such dependency.

Testing

Reproduced the venv failure directly, then confirmed the guard drops basedpyright and leaves the rest intact:

$ XDG_CONFIG_HOME=/tmp/cfg nvim --headless -c 'lua ... spec[2].opts.ensure_installed' -c qa
python3 venv unavailable (install python3-venv): skipping LSP server basedpyright
ensure_installed={ "ruff", "ts_ls", "svelte", "html", "cssls", "bashls" }

A full startup against the branch config emits the one warning and writes no new mason install-failure entries to ~/.local/state/nvim/mason.log.

Note that the container's ~/.config/nvim is a copy baked in at image build time, not a symlink to this checkout, so the dejima image needs a rebuild to pick either change up.

🤖 Generated with Claude Code

**Summary generated by LLM agent** Fixes the `[mason-lspconfig.nvim] failed to install basedpyright` error that appears on every nvim startup in the dejima container. ## Cause mason installs `basedpyright` from PyPI, which means creating a venv for it first (`mason-core/installer/managers/pypi.lua`). Debian ships venv's `ensurepip` in a separate `python3-venv` package rather than with `python3` itself, and the container image doesn't have it, so `python3 -m venv` exits 1: ``` $ python3 -m venv /tmp/vtest The virtual environment was not created successfully because ensurepip is not available. On Debian/Ubuntu systems, you need to install the python3-venv package [...] exit=1 ``` which matches the mason log exactly: ``` Installation failed for Package(name=basedpyright) error=spawn: python3 failed with exit code 1 and signal 0. ``` `ruff` installs fine alongside it because mason pulls that one as a prebuilt binary from a GitHub release, not from PyPI, so it never touches a venv. The `Provider "pypi" "get_supported_python_versions" failed: wget failed with exit code 4` line just above it in the log is a separate, transient startup race: pypi.org, files.pythonhosted.org and api.github.com are all reachable from the container, and that provider call failing only means mason skips the Python version compatibility check, it does not fail the install. ## Changes `packages/apt.global` gains `python3-venv`, which is the actual fix. Arch already bundles ensurepip with its `python` package, and `brew.global` installs a full `python`, so this only affects the Debian path. `config/nvim/lua/plugins/lsp.lua` now checks for venv support before adding `basedpyright` to `ensure_installed`, mirroring the `has_public_npm()` guard already there for the npm-sourced servers. On a machine that lacks it the user gets one warning naming the package to install, instead of a failed install on every startup. `ruff` is unconditional now that it is separated out, since it has no such dependency. ## Testing Reproduced the venv failure directly, then confirmed the guard drops `basedpyright` and leaves the rest intact: ``` $ XDG_CONFIG_HOME=/tmp/cfg nvim --headless -c 'lua ... spec[2].opts.ensure_installed' -c qa python3 venv unavailable (install python3-venv): skipping LSP server basedpyright ensure_installed={ "ruff", "ts_ls", "svelte", "html", "cssls", "bashls" } ``` A full startup against the branch config emits the one warning and writes no new mason install-failure entries to `~/.local/state/nvim/mason.log`. Note that the container's `~/.config/nvim` is a copy baked in at image build time, not a symlink to this checkout, so the dejima image needs a rebuild to pick either change up. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
dejima-agent added 1 commit 2026-08-17 14:37:01 -07:00
Debian ships venv's ensurepip in a separate python3-venv package. Without
it, `python3 -m venv` exits 1, so mason cannot build the venv it installs
basedpyright into, and mason-lspconfig reports a failed install on every
startup.

Add python3-venv to the apt package list, and guard the basedpyright entry
in ensure_installed the same way the npm-sourced servers are already
guarded, so a machine missing it gets one warning instead of a failed
install every time.
branderson approved these changes 2026-08-17 14:42:50 -07:00
branderson merged commit b0a2f0b132 into master 2026-08-17 14:42:56 -07:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: branderson/dotfiles#7