You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Don't set ${workspaceFolder} in settings.json #2459
Extension version (available under the Extensions sidebar): 2018.7.1
OS and version: Windows 10.0.17134.228 x64
Python version (& distribution if applicable, e.g. Anaconda): CPython 3.7.0 x64
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
Actual behavior
When python.pythonPath includes ${workspaceFolder}, tasks that use ${config:python.pythonPath} fail to start:
> Executing task: ${workspaceFolder}\venv\Scripts\python.exe setup.py build_ext --inplace <
The system cannot find the path specified.
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
Expected behavior
The tasks should start correctly. It's quite useful to use ${config:python.pythonPath} in your tasks so as to use the Python version used by vscode-python to run the tasks.
Steps to reproduce:
Create a virtualenv under your workspace: virtualenv venv
Select it as the Python interpreter of VS Code using the status bar. (python.pythonPath should be set to a path using ${workspaceFolder}).
Create a task that uses ${config:python.pythonPath} to run anything you want, and try to run it.
> Executing task: ${workspaceFolder}/venv/bin/python manage.py runserver <
/usr/local/bin/bash: /venv/bin/python: No such file or directory
The terminal process terminated with exit code: 127
Changing command to ${workspaceFolder}/venv/bin/python manage.py runserver works. Just using manage.py runserver doesn't work because the virtualenv isn't activated. Of course, if I were using pipenv, I'm guessing pipenv run manage.py runserver would do the job.
Aside: this makes me wonder if VS Code has a facility for defining a new task type, that would handle the virtualenv automatically.
Gotcha. Thanks for bumping this up the food chain.
I think one way this might still be an issue for this extension is that "python.pythonPath": "${workspaceFolder}/venv/bin/python" seems to be set automatically when the extension detects a virtual environment. But, that's incompatible with VS Code's variable substitution behavior as documented (and further discussed in microsoft/vscode#57551).
So, for this specific use case, it seems like automatically setting the python.pythonPath to either /Users/brian/Projects/my-project/venv/bin/python or just venv/bin/python would be preferable. But I'm guessing either of those could break other uses.
changed the title [-]When python.pythonPath includes ${workspaceFolder}, tasks that use ${config:python.pythonPath} fail to start[/-][+]Don't set ${workspaceFolder} in settings.json[/+]on Aug 31, 2018
Just to be sure I've understood, we don't need to change package.json (since the only substitutions are in the launch and task configs), right? From what I understand, we only need to change the places where we are adding substitutions to settings (e.g. in python.pythonPath).
Activity
bhrutledge commentedon Aug 29, 2018
I stumbled upon this issue by way of #1664.
My workspace settings (set automatically, I think):
{ "python.pythonPath": "${workspaceFolder}/venv/bin/python" }What I tried:
{ "label": "runserver", "type": "shell", "command": "${config:python.pythonPath} manage.py runserver", "problemMatcher": [], "group": { "kind": "build", "isDefault": true } }Output:
Changing
commandto${workspaceFolder}/venv/bin/python manage.py runserverworks. Just usingmanage.py runserverdoesn't work because the virtualenv isn't activated. Of course, if I were using pipenv, I'm guessingpipenv run manage.py runserverwould do the job.Aside: this makes me wonder if VS Code has a facility for defining a new task
type, that would handle the virtualenv automatically.brettcannon commentedon Aug 30, 2018
This issue was moved to microsoft/vscode#57551
brettcannon commentedon Aug 30, 2018
We don't' have anything to do directly with
tasks.json, so I have reported this upstream to VS Code.bhrutledge commentedon Aug 30, 2018
Gotcha. Thanks for bumping this up the food chain.
I think one way this might still be an issue for this extension is that
"python.pythonPath": "${workspaceFolder}/venv/bin/python"seems to be set automatically when the extension detects a virtual environment. But, that's incompatible with VS Code's variable substitution behavior as documented (and further discussed in microsoft/vscode#57551).So, for this specific use case, it seems like automatically setting the
python.pythonPathto either/Users/brian/Projects/my-project/venv/bin/pythonor justvenv/bin/pythonwould be preferable. But I'm guessing either of those could break other uses.[-]When python.pythonPath includes ${workspaceFolder}, tasks that use ${config:python.pythonPath} fail to start[/-][+]Don't set ${workspaceFolder} in settings.json[/+]brettcannon commentedon Aug 31, 2018
I've re-oriented the issue to change what the extension does.
1 remaining item
ericsnowcurrently commentedon Sep 25, 2018
Another point of reference (from the docs):
ericsnowcurrently commentedon Sep 25, 2018
Just to be sure I've understood, we don't need to change
package.json(since the only substitutions are in the launch and task configs), right? From what I understand, we only need to change the places where we are adding substitutions to settings (e.g. inpython.pythonPath).brettcannon commentedon Sep 25, 2018
Correct. The fact that we are injecting
${workspaceFolder}into people'spython.pythonPathsetting is what is breaking in thetasks.jsonusage.