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

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

Closed
schperplata opened this issue Sep 18, 2019 · 7 comments
Assignees
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster investigating We are looking into the cause of the issue

Comments

@schperplata
Copy link

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(R) Core(TM) 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%
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Sep 18, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Sep 18, 2019
@kimadeline
Copy link

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!

@kimadeline kimadeline added area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. needs PR bug Issue identified by VS Code Team member as probable bug and removed triage labels Sep 18, 2019
@schperplata
Copy link
Author

ping :) Has there been any progress here? It is not a blocker, but still, quite annoying.

@kimadeline
Copy link

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!

@karrtikr
Copy link

karrtikr commented Jun 7, 2022

@schperplata Did you use python.envFile setting in .code-workspace file?

@schperplata
Copy link
Author

@karrtikr Huh, that was a long ago, I don't remember what was the configuration option back then, to be honest.
Anyway, whatever the option was, it worked for workspace primary folder, but not for others.

In the meantime, we've been able to solve our issues with converting our folders to proper python packages and use venvs, and these issues were solved.
However, the issue is still valid (IMO) for other use cases in multi-folder wks, for example tool configuration where settings can be passed via .env file.

@karrtikr
Copy link

karrtikr commented Jun 8, 2022

Got it, unfortunately I'm unable to reproduce this issue when using the absolute path to .env file.

Anyway, whatever the option was, it worked for workspace primary folder, but not for others.

I suspect it was probably a user error, the way to set .env file is via the setting, so let's say you had the following setting in .code-workspace file:

"python.envFile": "${workspaceFolder}/.vscode/.env"

Now this will only work the for the first (primary) workspace folder as ${workspaceFolder} resolves differently for each folder. Instead if you specify:

"python.envFile": "${workspaceFolder:folder1}/.vscode/.env"

Or use the absolute path to the .env file, it would resolve it correctly. I think that is what was probably happening, and in that case this issue can be closed.

@karrtikr karrtikr self-assigned this Jun 8, 2022
@karrtikr karrtikr added info-needed Issue requires more information from poster investigating We are looking into the cause of the issue and removed needs PR labels Jun 8, 2022
@schperplata
Copy link
Author

Let's say it was so. :)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-intellisense LSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc. bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster investigating We are looking into the cause of the issue
Projects
None yet
Development

No branches or pull requests

4 participants