Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

python.autoComplete.extraPaths setting does not allow for environment variable substitution #1783

Open
hetsch opened this issue Oct 11, 2019 · 6 comments

Comments

@hetsch
Copy link

hetsch commented Oct 11, 2019

Environment data

  • VS Code version: 1.39.0
  • Extension version (available under the Extensions sidebar): 2019.10.41019
  • OS and version: Linux x64 5.0.0-31-generic snap
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.1
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): pyenv
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version vscode-python#3977): False, Microsoft Python Language Server version 0.4.58.0

Expected behaviour

"python.autoComplete.extraPaths": [
   "${env:HOME}/extra_packages"
],

should resolve to a path e.g.: /home/user/extra_packages

Actual behaviour

In my Output panel and Python Language Server target, it is resolved to

...
Interpreter search paths:
  /home/user/.pyenv/versions/3.7.1/lib/python3.7
  /home/user/.pyenv/versions/3.7.1/lib/python3.7/lib-dynload
  /home/user/.pyenv/versions/vscode/lib/python3.7/site-packages
User search paths:
  /home/user/${env:HOME}/extra_packages
...

If I hardcode my homedirectory in the setting python.autoComplete.extraPaths it works fine.

Steps to reproduce:

Just try to replace /home/user/extra_packages with ${env:HOME}/extra_packages in the python.autoComplete.extraPaths setting.

@brettcannon
Copy link
Member

Thanks for the bug report! We just wanted to quickly acknowledge we received it and we will be triaging it as soon as we can.

@ericsnowcurrently
Copy link
Member

@hetsch, by default VS Code supports variable substitution for only some of its own settings. Extensions can support variable substitution for their own settings, but they don't get much help from the VS Code API. In the case of the Python extension, we do support some variable substitution (see the supported variables). Unfortunately our documentation isn't very helpful here (I've opened a separate issue to improve them).

The main problem in your case is that the extension currently does not support substitution for "${env:HOME}" (or any "${env:*}" values). Is this something that used to work?

Otherwise I can change this issue to a feature request if you want. Just let us know. Thanks!

@hetsch
Copy link
Author

hetsch commented Nov 10, 2019

@ericsnowcurrently Sorry for responding so late. I can confirm that variable substitution worked before. I versioned my VSCode settings.json file and it seems that the bug was introducted after 10. Oct. 2019. Thank's for your help

@ericsnowcurrently
Copy link
Member

@hetsch, I was able to reproduce the problem, both under the latest release of the extension and with the September release. From what I can tell, the extension is doing the substitution properly. However, the language server also interprets your settings (sent by VS Code over the LSP) and it does not do any substitution. So I'm going to move this issue over to that team to see what can be done.

@ericsnowcurrently ericsnowcurrently transferred this issue from microsoft/vscode-python Nov 11, 2019
@ericsnowcurrently ericsnowcurrently removed their assignment Nov 11, 2019
@jakebailey
Copy link
Member

jakebailey commented Nov 11, 2019

Who is in charge of substitution? I thought the editor should have already preprocessed this data before it hits us. There are so many flavors of substitution that it's a bit much to try and do this in the LS itself.

@jakebailey
Copy link
Member

The only change that would have happened around this was that the LS started reading the user settings directly rather than the initialization options for things like paths, but that change happened a few months ago (#1492).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants