question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Environment (.env) file settings are not applied to all folders in VS Code multi-folder workspace

See original GitHub issue

Issue Type: Bug

PYTHONPATH variable in .env file is not respected in all folders of a VS Code multi-folder workspace. That cause autocomplete is unable to resolve paths and add recommendations while working on files that are not in a primary workspace folder (where .code-worskpace is located).

Workspace structure (all folders are added to .code-workspace):

- folder 1 (primary)
    - some python files
    - .code-workspace file (sets .env file)
    - .vscode/
        - tasks.json, launch.json. settings.json
        - .env
- folder 2:
    - some python files: py1.py, py2.py, py3.py, ...
    - .vscode/
         - settings.json (just an example of some modified option, like max line-width)
-folder 3:
    - some python files: py10.py, py11.py, py12.py, ...

I have defined PYTHONPATH to include ‘folder2’. I can import and see recomendations of a ‘folder 2’ files while I edit files in ‘folder1’, but not while I edit files in ‘folder3’. If I copy .env file and modify ‘folder3’ settings to use this file, it works.

So, question is: is this correct and expected behaviour? Are .env files, that are specified in .code-workspace meant to be used workspace-wide (eg. in all folders), or are .env files limited to a folder where .code-workspace is placed? Isn’t the whole point of multi-root workspaces to be able to use unified settings, eg. in one place (root .code-workspace)? I can execute (or use it in launch configuration) any module from another folders (folder2/3), but autocomplete does not work, which is bad. Also, have multiplied .env and other files is a bad idea - they need to be maintaned on multiple locations. Similar problem is described here.

Extension version: 2019.9.34911 VS Code version: Code 1.38.1 (b37e54c98e1a74ba89e03073e5a3761284e3ffb0, 2019-09-11T13:35:15.005Z) OS version: Windows_NT x64 10.0.17763

System Info
Item Value
CPUs Intel® Core™ i5-4570 CPU @ 3.20GHz (4 x 3193)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.89GB (7.47GB free)
Process Argv
Screen Reader no
VM 0%

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:7

github_iconTop GitHub Comments

2reactions
kimadelinecommented, Sep 18, 2019

Hi @schperplata 👋 Thank you for reaching out.

.env files specified in .code-workspace should be able to be used workspace-wide, which means that we have a bug here 🐛 I’ll add the appropriate triaging labels, thank you for reporting it!

1reaction
kimadelinecommented, Apr 1, 2020

We don’t give out ETAs, so no status. Feel free to 👍 your initial issue report to bump up its priority.

Thank you for your patience!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multi-root Workspaces in Visual Studio Code
You can open and work on multiple project folders in Visual Studio Code with ... (file, folder) settings are applied when using a...
Read more >
vscode multiroot workspace path environment variable
I would like to set default include paths at the workspace level relative to the .code-workspace file. Using ${workspaceFolder} resolves to the ...
Read more >
Visual Studio Code: Setting Environment Variable for Tasks
One of the key features of Visual Studio Code is its great debugging ... of workspaceFolder since multi-folder workspaces are now supported.
Read more >
Customize build debug tasks with JSON files - Visual Studio ...
Settings read from this file are applied to the parent directory of .vscode and all of its subdirectories. .gitignore .gitignore files are used...
Read more >
How to Configure VS Code Like a Pro | by Stefan Metodiev
The settings and functionality that you can have in a multi-folder workspace are exactly the same as with a normal workspace. There's no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found