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

"Configured debug type 'python' is installed but not supported in this environment" if using shellExecutionSupported in package.json #136712

Closed
kimadeline opened this issue Nov 9, 2021 · 36 comments
Assignees
Labels
*as-designed Described behavior is as designed debug Debug viewlet, configurations, breakpoints, adapter issues

Comments

@kimadeline
Copy link

kimadeline commented Nov 9, 2021

Does this issue occur when all extensions are disabled?: No

  • VS Code Version: 1.62.0, 1.63.0-insider commit a7104f1
  • Python extension version: 2021.11.1422169775 (stable), 2021.12.1436712109-dev (nightly)
  • OS Version: macOS Big Sur 11.6.1

(originally reported in microsoft/vscode-python#17952)

We recently added shellExecutionSupported to the when clause of features of the Python extension that shouldn't be exposed in virtual workspaces following the recommendation in microsoft/vscode-python#17493 (comment).

However, this now causes a Configured debug type 'python' is installed but not supported in this environment warning to be displayed:

image

Steps to Reproduce:

  1. Install the Python extension (either stable or nightly/Insiders) in local VS Code
  2. Activate it in a workspace with Python files
  3. Go to Run and Debug and add a new debug configuration of type Python File
  4. Open launch.json and note the squiggles under the configuration type.

If I remove the && shellExecutionSupported part on https://github.com/microsoft/vscode-python/blob/5f46b3daf288e91e825e03adf83516f35b8cc457/package.json#L1490 and rebuild the extension, the squiggles won't appear.

@weinand
Copy link
Contributor

weinand commented Nov 9, 2021

I can reproduce this in VS Code 1.62 (Stable) and 16.3 (Insiders).
The Python debugger contribution is not enabled, which explains the squiggly in the launch.json and the missing Python entry in the "environment Quickpick":

2021-11-09_11-10-03

However, running Python programs works fine...

The Python extension uses this when clause: "!virtualWorkspace && shellExecutionSupported".
Removing the "&& shellExecutionSupported" makes it work fine.

@alexr00 I noticed that "npm tasks" are controlled by a "when": "shellExecutionSupported"and they don't show this issue. Is there anything that we need to do in debug land to make the "shellExecutionSupported"context work correctly?

@isidorn since you've recommended to use the "shellExecutionSupported" context key, do you remember whether this has ever worked?

@weinand weinand added debug Debug viewlet, configurations, breakpoints, adapter issues bug Issue identified by VS Code Team member as probable bug labels Nov 9, 2021
@isidorn
Copy link
Contributor

isidorn commented Nov 9, 2021

@weinand I have not verified that the shellExecutionSupported context works. I have saw that this is being used by @alexr00 and @aeschli mentioned it so I thought it makes sense for this.

@alexr00
Copy link
Member

alexr00 commented Nov 9, 2021

@weinand I set shellExecutionSupported in the tasks service, but not immediately. Maybe the context is set too late for debug and so the debugger contribution is never enabled?

@weinand
Copy link
Contributor

weinand commented Nov 9, 2021

@alexr00 Thanks, that would explain it. What should we do?

@alexr00
Copy link
Member

alexr00 commented Nov 9, 2021

@weinand is there a way you can listen for the appropriate context change and and then update your contributions? Worth noting: I named those contexts after kinds of tasks, so it feels a little strange to use them in other places.

@weinand
Copy link
Contributor

weinand commented Nov 9, 2021

@alexr00 thanks for the suggestion

I agree that it was not a good idea to recommend piggy-backing on shellExecutionSupported in unrelated areas...

I think we have two options now:

  • tell clients (e.g. Python) to stop using shellExecutionSupported because it doesn't work outside of tasks (and it's semantically a stretch anyway), or
  • to promote it to a first-class context key with clear semantics and fixed behavior (i.e. early initialisation).

@alexr00 @aeschli @roblourens opinions?

@marknelson
Copy link

Seeing this pop up in my launch.json is a little perplexing, I don't follow the comments above, and from what I can see, the settings seem to apply to executing in a browser maybe? My apps are server-side command line apps, so the stuff being mentioned here seems to not even be germane to me.

@weinand
Copy link
Contributor

weinand commented Nov 9, 2021

the "popup in your launch.json" is just wrong - it's a bug in VS Code.

@jordanbui23
Copy link

I have run into this issue as well. I was following a Django tutorial on YouTube and one of the steps was to create a launch.json file and then run the debugger. It is giving me the error:

  • Configured debug type 'python' is installed but not supported in this environment.

I think I am in a shell virtual environment as well if that helps. Any input would be helpful.

@Olsthoorn
Copy link

I downgraded to the previous version, which solved the problem, including crashing of integrated terminal

@jordanbui23
Copy link

@Olsthoorn that got rid of the error. Thanks for the suggestion!

@roblourens
Copy link
Member

What are we trying to capture by using this context key? Is it, "the EH has 'real' compute"?

I see that the context key initially is false when we evaluate it to add that message to the debug adapter's schema, but becomes true later.

@weinand
Copy link
Contributor

weinand commented Nov 10, 2021

@kimadeline above you said:

We recently added shellExecutionSupported to the when clause of features of the Python extension that shouldn't be exposed in virtual workspaces following the recommendation in microsoft/vscode-python#17493 (comment).

Does this mean that the !virtualWorkspace "when" clause was not sufficient?

@alexr00
Copy link
Member

alexr00 commented Nov 10, 2021

@weinand I would opt for option 1, where shellExecutionSupported isn't used outside of tasks. The context is documented and suggested for task definitions as is.

@marknelson
Copy link

the "popup in your launch.json" is just wrong - it's a bug in VS Code.

Would be nice to have some end user advice on this - right now it's all insider talk about resolution. Agreed that this is necessary but I hate having a non-empty problem list.

@weinand
Copy link
Contributor

weinand commented Nov 10, 2021

As suggested above by @Olsthoorn:

downgrade to the previous version

@weinand
Copy link
Contributor

weinand commented Nov 10, 2021

@kimadeline I agree with @alexr00 that our earlier recommendation was wrong and that the context key shellExecutionSupported should not be used outside of tasks.

I suggest that you remove the shellExecutionSupported from the when-clauses and publish a new version of the Python extension to the Marketplace.

If the reason for adding shellExecutionSupported was a problem with the virtualWorkspace context key, please create a new issue for this.

@weinand weinand added *as-designed Described behavior is as designed and removed bug Issue identified by VS Code Team member as probable bug labels Nov 10, 2021
@weinand weinand closed this as completed Nov 10, 2021
@kimadeline
Copy link
Author

@weinand our current when clause is "when": "!virtualWorkspace && shellExecutionSupported". Which combination of context keys should we use for features that we want to disable in virtual workspaces and github.dev/vscode.dev?

@weinand
Copy link
Contributor

weinand commented Nov 10, 2021

@kimadeline so "!virtualWorkspace" is not sufficient?

@kimadeline
Copy link
Author

afaik !virtualWorkspace doesn't work when opening local folders in vscode.dev, so we added shellExecutionSupported.

@weinand
Copy link
Contributor

weinand commented Nov 10, 2021

@kimadeline please file a feature request for a new context key for this situation.

@aeschli
Copy link
Contributor

aeschli commented Nov 12, 2021

@weinand Regardless of which content key we recommend, debug needs to listen for changes to the context key is depends on and trigger a schema update. Example.

@kimadeline Until we conclude whether we need a new key or not, you can always define your own context key in the extension matching exactly your use case. Here is an example to that.

@weinand
Copy link
Contributor

weinand commented Nov 12, 2021

@aeschli you said:

Regardless of which content key we recommend, debug needs to listen for changes to the context key it depends on and trigger a schema update.

That shows exactly the problem: context keys are not scoped, so the Python extension can use Task's shellExecutionSupported context key to control a Debug contribution. We did not plan that, so we are not listening for shellExecutionSupported changes (and we have no intentions to do so because the semantics of shellExecutionSupported is not obvious for debug).

and if @kimadeline would introduce their own context key in the Python extension, how could Debug listen for that?

@aeschli
Copy link
Contributor

aeschli commented Nov 15, 2021

@weinand The set of context variable that can be used in when clauses is open. But you can ask the when clause for the variables it contains. (IContextKeyExpression.keys) and listen for context key changes (IContextKeyService.onDidChangeContext with IContextKeyChangeEvent.affectsSome)

@roblourens
Copy link
Member

We don't listen to updates for individual context keys, we just listen to any change in the context and update the schema to show or hide the warning.

@roblourens roblourens reopened this Nov 15, 2021
@roblourens
Copy link
Member

roblourens commented Nov 15, 2021

Sorry, needed to refresh the page and didn't see the latest

@shanewazabbas
Copy link

When does the fix get released. I had to downgrade two versions to remove the message.

@hunglnguyen
Copy link

Uninstall Jupyter, then re-install should resolve it.
Jupyter Screenshot
er

@zchrissirhcz
Copy link

Uninstall Jupyter, then re-install should resolve it.

So magic! Works for me. Thanks very much.

@subfuzion
Copy link

Strange, but for me I also had to uninstall and reinstall python in addition to Jupyter. In any case, uninstalling was definitely the nudge in the right direction. (Thanks @hunglnguyen)

@BrendanSimon
Copy link

Uninstalling and reinstalling Jupyter also worked for me.

Version: 1.62.3 (user setup)
Commit: ccbaa2d27e38e5afa3e5c21c1c7bef4657064247
Date: 2021-11-17T08:11:14.551Z
Electron: 13.5.2
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19043

@thejoecodes
Copy link

thejoecodes commented Dec 6, 2021

Had to uninstall Python and Jupyter and restart VS Code and reinstall both. It worked! Thank you

@floatingpurr
Copy link

floatingpurr commented Dec 7, 2021

Uninstalling and reinstalling Jupyter also worked for me.

Version: 1.62.3 (user setup)
Commit: ccbaa2d27e38e5afa3e5c21c1c7bef4657064247
Date: 2021-11-17T08:11:14.551Z
Electron: 13.5.2
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19043

Any idea about how to get rid of this error without dealing with Jupyter?

@yang-yuke
Copy link

Uninstall Jupyter, then re-install should resolve it. Jupyter Screenshot er

Bro, thank you so much. Your reply is the exactly one we need. It works like magic!

@Csega
Copy link

Csega commented Dec 8, 2021

Uninstall Jupyter, then re-install should resolve it. Jupyter Screenshot er

Bro, thank you so much. Your reply is the exactly one we need. It works like magic!

Not working for me... :(

EDIT: Sorry guys, I just had to delete the whole launch.json file from my folder, which was created during this struggle... It works now like a charm! :)

@srcolinas
Copy link

Lol, very unexpected fix

@github-actions github-actions bot locked and limited conversation to collaborators Dec 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed debug Debug viewlet, configurations, breakpoints, adapter issues
Projects
None yet
Development

No branches or pull requests