Skip to content

Commit e70ef0a

Browse files
elvinzengclaude
andauthored
[python] Fix incorrect VIRTUAL_ENV in pyenv-mode-set-local-version (#17246)
Remove the erroneous `(setenv "VIRTUAL_ENV" version)` call from `spacemacs//pyenv-mode-set-local-version`. This line was introduced in commit e699763 to help Python LSP servers detect pyenv version changes. However, the implementation was incorrect: it set `VIRTUAL_ENV` to a bare version string (e.g. "3.13.2") instead of a filesystem path. The `VIRTUAL_ENV` environment variable, by convention, should contain the absolute path to a virtualenv directory. This causes issues in pyenv + Poetry workflows: Poetry reads `VIRTUAL_ENV` and interprets the version string as a virtualenv path, leading to errors. The severity depends on hook execution order — if `spacemacs//python-setup-backend` (which calls `poetry-venv-workon` → `pyvenv-activate`) runs after the pyenv hook, the bogus value gets overwritten and the bug is masked; otherwise Poetry breaks. The `setenv` call is also unnecessary. `pyenv-mode-set` already handles all required environment setup internally: - calls `pythonic-activate` with the full path from `pyenv-mode-full-path` to set `python-shell-virtualenv-root` - sets `PYENV_VERSION` to the version string Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bbce098 commit e70ef0a

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

layers/+lang/python/funcs.el

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ Equivalent to: autoflake --remove-all-unused-imports --in-place <FILE>"
243243
(line-beginning-position)
244244
(line-end-position)))))))
245245
(cond ((member version (pyenv-mode-versions))
246-
(setenv "VIRTUAL_ENV" version)
247246
(pyenv-mode-set version))
248247
(t (message "pyenv: version `%s' is not installed (set by %s)"
249248
version file-path)))))

0 commit comments

Comments
 (0)