Skip to content

ty.interpreter setting does not expand ${workspaceFolderBasename} variable (partial variable expansion) #292

@keuj6

Description

@keuj6

Description

The ty.interpreter setting only partially expands VS Code variables. While ${env:USERNAME} expands correctly, ${workspaceFolderBasename} remains as a literal string, causing ty to fail finding the Python environment.

Steps to Reproduce

  1. Create a project with venv stored outside the project directory using a consistent naming pattern
  2. Add to .vscode/settings.json:
   {
     "ty.interpreter": [
       "C:\\Users\\${env:USERNAME}\\venv\\${workspaceFolderBasename}\\Scripts\\python.exe"
     ]
   }
  1. Open the project in VS Code
  2. Check "ty: Show client logs" (Command Palette → ty: Show client logs)

Expected Behavior

For a project named myproject with username john, the path should expand to:

C:\Users\john\venv\myproject\Scripts\python.exe

Both ${env:USERNAME} and ${workspaceFolderBasename} should be expanded.

Actual Behavior

The path expands to:

C:\Users\john\venv\${workspaceFolderBasename}\Scripts\python.exe
  • ${env:USERNAME}john (works)
  • ${workspaceFolderBasename} → remains literal (doesn't work)

Log Evidence

Client log:

[error] Unable to find any Python environment for the interpreter path: C:\Users\john\venv\${workspaceFolderBasename}

Use Case / Motivation

Supporting team environments where developers store venvs outside the project directory with consistent naming:

C:\Users\alice\venv\project1\
C:\Users\alice\venv\project2\
C:\Users\bob\venv\project1\
C:\Users\bob\venv\project2\

Current Workaround

Must hardcode the project name in workspace settings (not ideal for shared configs):

{
  "ty.interpreter": [
    "C:\\Users\\${env:USERNAME}\\venv\\myproject\\Scripts\\python.exe"
  ]
}

This requires:

  • .vscode/settings.json to be gitignored
  • Each team member to manually update their settings with their project name
  • Maintaining a .vscode/settings.json.example template

Environment

  • ty-vscode version: 2026.4.0
  • ty version: 0.0.12
  • VS Code version: 1.108.0
  • OS: Windows 10
  • Python version: 3.13.7

Additional Context

This appears to be a common issue with VS Code extensions. Variable substitution is not automatic and must be implemented by each extension (VS Code issue #46471).

Metadata

Metadata

Assignees

No one assigned

    Labels

    configurationRelated to settings and configuration

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions