Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspace environment variable ${workspaceFolder} is not being set/empty on WSL #24818

Closed
enda-quantmatix opened this issue Feb 13, 2025 · 2 comments
Assignees
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@enda-quantmatix
Copy link

enda-quantmatix commented Feb 13, 2025

Type: Bug

I develop using WSL on my Windows machine. I use the Remote plugin to connect to my Ubuntu 22.04 instance and open folders from there.

Issue:

I have been running into a consistent problem where my ${workspaceFolder} environment variable is not being set, it is empty. I have confirmed this by setting my "PYTHONPATH" to "PYTHONPATH=${workspaceFolder}" in a .env file and from the terminal, after loading in variables from this .env file I run echo $PYTHONPATH and it returns empty. I have double checked this by opening the same folder in vscode running on Windows and it is set correctly here. The correct path should be "/home/enda/QuantStudies"

Running on WSL using Remote plugin:
Image

Opened folder workspace:
Image

Empty python path variable which should be set to ${workspaceFolder}
Image

.env file used to set the PYTHONPATH to the ${workspaceFolder}
Image

Confirmed this gets set when I open the same repo on Windows
Image

VS Code version: Code 1.97.1 (e249dada235c2083c83813bd65b7f4707fb97b76, 2025-02-10T13:13:58.153Z)
OS version: Windows_NT x64 10.0.26100
Modes:
Remote OS version: Linux x64 5.15.133.1-microsoft-standard-WSL2

System Info
Item Value
CPUs 13th Gen Intel(R) Core(TM) i7-13700H (20 x 2918)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 63.68GB (36.99GB free)
Process Argv --crash-reporter-id 7257fdfd-9e42-4679-885c-0a54843c85bf
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu
OS Linux x64 5.15.133.1-microsoft-standard-WSL2
CPUs 13th Gen Intel(R) Core(TM) i7-13700H (20 x 0)
Memory (System) 47.05GB (41.62GB free)
VM 0%
Extensions (115)
Extension Author (truncated) Version
project-manager ale 12.8.0
zoomer ant 0.3.1
docs-view bie 0.1.0
vsc-python-indent Kev 1.19.0
mssql-snippets MEn 0.4.0
vscode-azurevirtualmachines ms- 0.6.6
jupyter-keymap ms- 1.1.2
remote-containers ms- 0.397.0
remote-ssh ms- 0.117.1
remote-ssh-edit ms- 0.87.0
remote-wsl ms- 0.88.5
vscode-remote-extensionpack ms- 0.26.0
remote-explorer ms- 0.4.3
remote-server ms- 1.5.2
gruvbox-material sai 6.5.2
swdc-vscode sof 2.8.3
open-in-browser tec 2.0.0
errorlens use 3.23.0
vscode-icons vsc 12.11.0
vscode-todo-highlight way 1.0.5
jinja who 0.0.8
project-manager ale 12.8.0
alignment ann 0.3.0
zoomer ant 0.3.1
vscode-django bat 1.15.0
docs-view bie 0.1.0
dbclient-jdbc cwe 1.3.9
vscode-myssql-client2 cwe 8.1.4
vscode-markdownlint Dav 0.58.2
docs-article-templates doc 1.0.8
docs-authoring-pack doc 1.0.2
docs-build doc 0.4.6
docs-images doc 1.0.4
docs-markdown doc 1.0.12
docs-preview doc 1.0.9
docs-scaffolding doc 1.0.8
docs-yaml doc 1.0.5
githistory don 0.6.20
python-environment-manager don 1.2.7
python-extension-pack don 1.7.0
parquet-viewer dvi 2.11.1
gitlens eam 16.3.0
prettier-vscode esb 11.0.0
git-project-manager fel 1.8.2
code-runner for 0.12.2
c-cpp-runner fra 9.4.10
copilot Git 1.270.0
copilot-chat Git 0.24.0
vscode-pull-request-github Git 0.104.0
gc-excelviewer Gra 4.2.63
todo-tree Gru 0.0.226
prettier-sql-vscode inf 1.6.0
vscode-colorize kam 0.16.0
vsc-python-indent Kev 1.19.0
Learn-Training-AI-Assistant Lea 1.1.53
rainbow-csv mec 3.17.0
mssql-extensions-starter-pack MEn 0.2.0
mssql-scripts MEn 0.4.0
mssql-snippets MEn 0.4.0
git-graph mhu 1.30.0
prettify-json moh 0.0.3
azure-dev ms- 0.8.4
vscode-azure-github-copilot ms- 0.3.97
vscode-azureappservice ms- 0.25.4
vscode-azurecontainerapps ms- 0.8.0
vscode-azurefunctions ms- 1.16.2
vscode-azureresourcegroups ms- 0.10.4
vscode-azurestaticwebapps ms- 0.13.0
vscode-azurestorage ms- 0.16.2
vscode-azurevirtualmachines ms- 0.6.6
vscode-cosmosdb ms- 0.24.2
vscode-docker ms- 1.29.4
csdevkit ms- 1.16.6
csharp ms- 2.63.32
vscode-dotnet-runtime ms- 2.2.8
vscodeintellicode-csharp ms- 2.2.3
data-workspace-vscode ms- 0.5.0
mssql ms- 1.28.0
sql-bindings-vscode ms- 0.4.0
sql-database-projects-vscode ms- 1.4.5
debugpy ms- 2025.0.1
python ms- 2025.0.0
vscode-pylance ms- 2025.2.1
datawrangler ms- 1.18.2
jupyter ms- 2025.1.0
jupyter-keymap ms- 1.1.2
jupyter-renderers ms- 1.1.0
vscode-jupyter-cell-tags ms- 0.1.9
vscode-jupyter-slideshow ms- 0.1.6
azurecli ms- 0.6.0
cmake-tools ms- 1.19.52
cpptools ms- 1.23.6
cpptools-extension-pack ms- 1.3.0
vscode-node-azure-pack ms- 1.3.0
sqltools mtx 0.28.3
sqltools-driver-mssql mtx 0.4.3
autodocstring njp 0.6.1
vscode-yaml red 1.16.0
gruvbox-material sai 6.5.2
markdown-preview-enhanced shd 0.8.15
swdc-vscode sof 2.8.3
even-better-toml tam 0.21.2
find-it-faster Tom 0.0.39
cmake twx 0.0.17
errorlens use 3.23.0
vscode-lldb vad 1.11.3
intellicode-api-usage-examples Vis 0.2.9
vscodeintellicode Vis 1.3.2
vscode-icons vsc 12.11.0
vscode-todo-highlight way 1.0.5
gruvbox-concoctis whe 10.30.27
jinja who 0.0.8
zoombar-vscode wra 1.4.4
markdown-all-in-one yzh 3.6.2
json Zai 2.0.2

(14 theme extensions excluded)

A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt551:31179978
vscod805:30301674
binariesv615:30325510
py29gd2263:31024239
vscaac:30438847
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc2:31192216
iacca1:31171482
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624
hdaa2157:31222309
copilot_t_ci:31222730
cp15172_c:31236637
jda6j935:31233686

@enda-quantmatix enda-quantmatix changed the title Workspace environment variable is not being set Workspace environment variable ${workspaceFolder} is not being set/empty on WSL Feb 13, 2025
@vs-code-engineering vs-code-engineering bot added the triage-needed Needs assignment to the proper sub-team label Feb 13, 2025
@deepak1556 deepak1556 assigned aeschli and unassigned deepak1556 Feb 13, 2025
@vs-code-engineering vs-code-engineering bot removed the triage-needed Needs assignment to the proper sub-team label Feb 13, 2025
@aeschli aeschli transferred this issue from microsoft/vscode Feb 14, 2025
@aeschli aeschli removed their assignment Feb 14, 2025
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 14, 2025
@aeschli
Copy link

aeschli commented Feb 14, 2025

${workspaceFolder} is a VS Code internal variable that can be used with certain VS Code settings or in VS Code launch configurations.
You can't use it in .env files unless you have defined an OS env variable with that name.
When running on WSL, OS env variables are defined through the shell configuration scripts like .bashrc or can be exported from Windows. VS Code doesn't add or remove anything here.

@enda-quantmatix
Copy link
Author

enda-quantmatix commented Feb 17, 2025

Thanks for the response and the clarification.

I forgot to add that I do also have a settings.json where I also try to set the PYTHONPATH using the ${workspaceFolder}. However, I just discovered that the setting I was using was for Windows and not Linux!

I added
"terminal.integrated.env.linux": { "PYTHONPATH": "${workspaceFolder}" },
and that has fixed my issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

4 participants