posit-dev / posit-dev/positron

Python: `VIRTUAL_ENV` and other variables exposed in R even when no Python is selected

Open
#7,872 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: reticulate lang: python
Dominant language
TypeScript
Stars
4.3k
Forks
184
Avg merge
1d 9h
Merged PRs (30d)
195

Description

System details:

Positron and OS details:
Positron Version: 2025.06.0 (Universal) build 146
Code - OSS Version: 1.100.0
Commit: 5d50f3662904bba480b1dc856073f3ad19a1ddd0
Date: 2025-05-27T03:33:41.580Z
Electron: 34.5.1
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Darwin arm64 24.5.0
Interpreter details:

Any

Describe the issue:

Even with no Python version selected in Positron, the Python extension detects a default Python and contributes environment variables to the Terminal and Console to use the detected version. This can be undesirable, especially in the Console when trying to use cross-language features like reticulate.

Steps to reproduce the issue:

  1. Open a workspace containing only R files on a system with at least one Python installation.
  2. Use the Clear Saved Interpreter command to double check that Python is in no way affiliated with the workspace.
  3. Start an R session.
  4. Check the environment variables PATH and VIRTUAL_ENV. PATH includes a Python installation, and VIRTUAL_ENV will too if a virtual environment was detected.

Why is this a problem? Via @t-kalinowski:

The biggest practical issue with this for R users is that it preempts reticulate's Python discovery. So any packages that use reticulate and may default to the new uv-reticulate behavior do not work in Positron.

Expected or desired behavior:

These values are registered as terminal environment contributions, so there are several approaches we could take, each with some tradeoffs.

  • Don't allow R or Python to contribute to each others' environments in the Console. That is, when forming the set of environment variables we want to use, ignore any that were set by an extension that is a language pack (other than our own). Downside: Calling Python from R via e.g. system2 won't get the right version, etc.
  • Don't allow Python to contribute any vars that point to a specific Python if the user hasn't chosen one. Downside: Python might not work in the Terminal or Console unless it was already on the $PATH.
  • Specifically exclude VIRTUAL_ENV since that seems to be the one causing practical trouble.
  • Do some combination of the above, but gated for reticulate users only (as this is an opt in setting, we can identify them reliably)
  • Run away from home and live in the woods

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue by clearing the saved interpreter, starting an R session in a workspace with only R files, and checking PATH and VIRTUAL_ENV. Trace how terminal environment contributions from the Python extension reach the Console, then clarify which proposed behavior should be implemented and verify that R sessions no longer receive unintended Python-specific variables.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, r
Domain
developer-experience
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.