-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Activation issue: activation incorrectly using cmd not bat #23037
Comments
I have the same issue with test discovery triggering a pop-up. Corresponds to the log below in the Output->Python.
|
Hi! Could you provide a screenshot of this popup you are referencing? I am not sure exactly what you are talking about. Thanks! |
Kinda hard to get a screenshot since the popup is so short. Here's a video showing the issue. Untitled.video.-.Made.with.Clipchamp.mp4In the video I change the code and save the file (CTRL + S) to trigger a test rediscovery. The popup doesn't appear in other workspaces, only Python workspaces with testing set up. |
thanks for the video, that is very helpful! I have never seen this issue before- let me talk with some colleagues and circle back. |
one quick question: do you have any workspace or user settings having to do with saving like |
I didn't have either of those two in my settings files (attaching here both my user settings.json I tried adding the two settings and changing their values, but it didn't seem to have any effect. The test discovery still runs and triggers a popup, regardless of the two settings. |
@karthiknadig any ideas here? I am not seeing any settings that I think could trigger this |
Do we use shell execute when running tests? If that is yes, then command prompt initialization script that sets up |
we spawn with child_process so it might apply, @MatejVitek could you check on your conda init script? You could also try creating a venv without conda and running tests to see if conda is a common factor in the popup occurring which would give us more direction. Thanks |
@MatejVitek You might need to check the file that |
I have checked some more and it turns out any |
@karthiknadig how do we set what shell is used when we run a subprocess? |
As a note, other users seem to be experiencing similar issues with cmd popups being triggered by conda installations on Windows. For example, see this issue in another repo. Also, I found this older issue that seems to describe a similar problem with cmd triggering a popup, and the use of Powershell resolving the issue. It may be worth giving the user the option to choose the shell that's used (if not already the case) or simply use the same shell that's used elsewhere. |
@eleanorjboyd One thing we can try is to pass process creation flags to the runner. Try setting |
I see the popup when |
Hi @tonibofarull- did you check your conda init script? Or do you have any settings which could be related? Please send your settings over if you are still experiencing issues and also your logs from the python output channel. |
I just want to clarify, this has nothing to do with python extension itself. This is an issue with conda and its init script. Note that even if you set to use a different shell with VS Code, if you have services that rely on the faulty shell init script it can cause issues on your system. I recommend looking at the init scrips for various cases and see if something is causing this. The cause of this seems to be ContinuumIO/anaconda-issues#10593 @eleanorjboyd The |
In my case this is happening with virtualenv. Not conda! I'll share the logs tomorrow since now I'm not on my PC. |
Great thanks! |
Now I understand my issue. To reproduce,
and create from kivymd.app import MDApp
def test_a():
pass VSCode logs,
It seems to me that the option |
you can also turn off test discovery on save which might fix the pop happening on save and instead you can trigger it yourself when you want to execute test discovery. The setting to do so is: "python.testing.autoTestDiscoverOnSaveEnabled": false |
Oh thanks! |
I have isolated the issue and I think I have a solution (maybe) -- but I don't know how to patch it in VS Code without getting my hands dirty. TLDR: VS Code is calling a bash script instead of the I personally noticed that the cmd.exe prompt appears in VS Code when in the Python "Output" tab the following is run: ~/miniforge3/Scripts/activate ; conda activate science ; echo '<some string>' . python ~/.vscode/extensions/ms-python.python-2024.4.1/python_files/printEnvVariables.py When I run this command in my Powershell prompt, the cmd.exe window appears. On the other hand if I run the same with Prior ArtThis is pointed out in #20836 comment which is linked above in this thread:
There was the response:
which I cannot validate the claims of, since the What is
|
@karthiknadig, could you review the comment above and let me know your thoughts? Thanks |
Hi @MatejVitek, thank you so much for this in-depth investigation! You are totally correct and this is a bug that will need to be resolved. Updating the title to reflect the specific bug and adding the correct labels now. Thanks |
Any update on this? I'm also running Miniforge3 on windows and I didn't create second conda environment. The following command will trigger a command prompt
It's very annoying. |
@machsix This issue is particularly about using the activate script for running project code. Here we are in some cases picking the wrong activate script. But |
Yes,
Yes, it occurs whether I run the command in powershell or command prompt. I think the issue you mentioned is a bug of Anaconda navigator but not conda? |
If this occurs outside of VS Code with
I based it on the |
Ok, I went through some debug and found my issue is not related to either vscode-python or conda. Here is what happened in my case, I'm telling in the sequence of launching
@SET "PATH=xxxxx"
@SET "CONDA_PREFIX=C:\Python\miniforge3"
@SET "CONDA_SHLVL=1"
@SET "CONDA_DEFAULT_ENV=base"
@SET "CONDA_PROMPT_MODIFIER=(base) "
@SET "CONDA_EXE=C:\Python\miniforge3\Scripts\conda.exe"
@SET "_CE_M="
@SET "_CE_CONDA="
@SET "CONDA_PYTHON_EXE=C:\Python\miniforge3\python.exe"
@CALL "C:\Python\miniforge3\etc\conda\activate.d\khronos-opencl-icd-loader_activate.bat"
@CALL "C:\Python\miniforge3\etc\conda\activate.d\libxml2_activate.bat"
@CALL "C:\Python\miniforge3\etc\conda\activate.d\openssl_activate-win.bat"
@CALL "C:\Python\miniforge3\etc\conda\activate.d\proj4-activate.bat" The line Update: I can confirm the commit conda-forge/khronos-opencl-icd-loader-feedstock@eb8e0d6 fixes my issue. |
hi! How do I install the update? Do I just change that bat file to the new version? I appear to have a lot of "activate.bat" files and "recipe" folders in my miniconda installation and not sure which one to change |
I have disabled this setting but still getting the popups unfortunately. It started happening when I selected >Python: Configure Tests. Unfortunately I do not know how to undo that. I am okay with running tests from cmd, but how do I disabled tests? |
@inikishev You can set the unittest or pytest setting in your settings.json to false. |
hi, thanks for the reply! I didn't see anything related to unittest or pytest in my settings.json, however I found that the setting is called |
Hey @karthiknadig, this issue might need further attention. @MatejVitek, you can help us out by closing this issue if the problem no longer exists, or adding more information. |
I have tried the fixes outlined in this thread, but the problem was not resolved for me. However, the comment I previously made no longer holds, as now I don't get any popup windows when running Since I'm not having these issues on my (very similar) home installation, I intend to reinstall conda/mamba on my work PC in the future to see if that resolves the issue. However, I can't do that at the moment, as I have a very fragile conda environment set up for my work that will not be reproducible if I reinstall conda. |
@MatejVitek sorry for the delay- any updates on your end or still seeing this problem? |
@eleanorjboyd I have now fully reinstalled VSCode and Mamba, and I'm currently not seeing any popups, even with test auto-discovery turned on. I will close this thread for the time being and will reopen it if the issue reoccurs. |
Sounds good! Let me know if anything changes- happy coding! |
Uploading Python.log…
Type: Bug
Behaviour
Expected vs. Actual
Expected: I can code without interruptions.
Actual: Command prompt windows keep popping up, stealing focus from VSCode and making it difficult to write code.
Steps to reproduce:
I'm not certain how to reproduce the problem in general, but I've narrowed it down to the use of Pytest. After a clean reinstall, the issue wasn't present until I enabled Pytest in VSCode's Testing tab.
Studying the Python log in the Output tab, I noticed that whenever the window pops up, the following appears in the log:
Trying to exectue the above
conda run
command manually gives me an error, since ~ is not a thing in powershell or command prompt.This issue only started appearing in the last month or two, prior to that I could use Pytest on the same machine with no issues.
Diagnostic data
python.languageServer
setting: PylanceOutput for
Python
in theOutput
panel (View
→Output
, change the drop-down the upper-right of theOutput
panel toPython
)User Settings
Extension version: 2024.2.1
VS Code version: Code 1.87.0 (019f4d1419fbc8219a181fab7892ebccf7ee29a2, 2024-02-27T23:41:44.469Z)
OS version: Windows_NT x64 10.0.19045
Modes:
System Info
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
The text was updated successfully, but these errors were encountered: