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

python.venvPath config setting does not expand variables #189

Closed
ashb opened this issue Dec 10, 2020 · 12 comments
Closed

python.venvPath config setting does not expand variables #189

ashb opened this issue Dec 10, 2020 · 12 comments

Comments

@ashb
Copy link

ashb commented Dec 10, 2020

I'm migrating from coc-python, and I have this in my global config file

  "python.venvPath":"~/.virtualenvs",

Previously this worked, but now I see the following message in the pyright output:

[Error  - 12:17:32] venvPath /home/ash/code/airflow/airflow/~/.virtualenvs is not a valid directory.

I also tried with $HOME, neither worked.

Please could one of these expansion mechanisms work before the config is passed on to pyright?

@fannheyward
Copy link
Owner

No, Pyright server gets configurations by sending workspace/configuration to client, coc responses contents from package.json, so expansion does nothing.

@ashb
Copy link
Author

ashb commented Dec 11, 2020

Expansion used to work for the previous provider.

I'd really like to not have to have a custom config per machine I run on (where my username is different).

Are you saying this isn't possible and we can't fix it? Should I open this as a feature request against pyright?

@fannheyward
Copy link
Owner

Expansion used to work for the previous provider.

What do you mean previous provider?

@ashb
Copy link
Author

ashb commented Dec 11, 2020

coc-python, sorry.

Anyway your comment was enough to point me in the right direction, and I have opened microsoft/pyright#1267

@ashb
Copy link
Author

ashb commented Dec 13, 2020

For anyone coming across this issue, the fix is (or will be when next pyright release happens) is to use ${env:HOME}

@ashb
Copy link
Author

ashb commented Dec 16, 2020

@fannheyward A question about developing this extension/pyright itself using this: is there any easy way I can point at a custom pyright install? I'm trying to debug the above linked issue and would like to do so in by running it "as I normally do" -- from within nvim.

Is this possible?

@fannheyward
Copy link
Owner

Replace your build with ~/.config/coc/extensions/coc-pyright/node_modules/pytight

@g6ai
Copy link

g6ai commented Apr 26, 2021

For anyone coming across this issue, the fix is (or will be when next pyright release happens) is to use ${env: HOME}

Could you elaborate how to make this work please? I tried to set it to:

{
  "python.venvPath": "${env: HOME}/.pyenv/versions"
}

but no luck. (The absolute path, for me it's /Users/gbai/.pyenv/versions, is working)

Interestingly, relative paths work for python.formatting.blackPath and python.sortImports.path. E.g. I have created a venv called coc that has black and isort installed:

{
   "python.formatting.blackPath": "~/.pyenv/versions/coc/bin/black",
   "python.sortImports.path": "~/.pyenv/versions/coc/bin/isort"
}

and relative path works in those settings.

@ashb
Copy link
Author

ashb commented Apr 26, 2021

@g6ai This is what I have in my global coc-settings.json

  "python.venvPath":"${env:HOME}/.virtualenvs",

Probably no space after the :

@g6ai
Copy link

g6ai commented Apr 26, 2021

@ashb You are right, it works!

@ashb
Copy link
Author

ashb commented Apr 27, 2021

Updated my original comment.

@Dhruv-mak
Copy link

I have virtualenv already installed. But I can't find any ~/.pyenv, ~/Envs, ~/.virtualenvs. I am using windows. What should be the value of pyhton.venvPath in my coc-settings.json.

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

No branches or pull requests

4 participants