Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was 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

Description

@hetsch

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.

Activity

  1. brettcannon commented on Oct 16, 2019

    @brettcannon
    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.

  2. ericsnowcurrently commented on Oct 30, 2019

    @ericsnowcurrently

    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!

  3. hetsch commented on Nov 10, 2019

    @hetsch
    Author

    Eric Snow (@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

  4. ericsnowcurrently commented on Nov 11, 2019

    @ericsnowcurrently

    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.

  5. jakebailey commented on Nov 11, 2019

    @jakebailey
    Member

    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.

  6. jakebailey commented on Nov 11, 2019

    @jakebailey
    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions