posit-dev / positron

Positron, a next-generation data science IDE
Other
2.39k stars 70 forks source link

IPyKernel may be installed with a missing `pygments` dependency #3270

Open seeM opened 3 months ago

seeM commented 3 months ago

Positron Version:

Positron Version: 2024.05.0 (Universal) build 1307

Steps to reproduce the issue:

I unfortunately don't have a good repro yet.

This happened on a homebrew Python 3.12.3 installation, but I'm not sure how I got into that state. Due to #2248, it also wouldn't be clear to a user what went wrong or how to remedy the issue (logs included below). It's pretty straightforward to fix in this case, with pip install pygments (ensuring I do so in the same environment).

What did you expect to happen?

If there are any missing required dependencies, I should see a modal prompting me to install them. I also shouldn't end up in the state where I have some dependencies but not others.

Were there any error messages in the output or Developer Tools console?

Runtime logs ```log [Positron] Python 3.12.3 (Global) failed to start; exit code: 1 [Python] /opt/homebrew/bin/python3 /Applications/Positron.app/Contents/Resources/app/extensions/positron-python/python_files/positron/positron_language_server.py -f /var/folders/_r/pm17dpfn7lx5mf3wtd96kw3m0000gn/T/kernel-djTOtv/connection.json --logfile /var/folders/_r/pm17dpfn7lx5mf3wtd96kw3m0000gn/T/kernel-djTOtv/kernel.log --loglevel=error --session-mode=console [Python] Traceback (most recent call last): [Python] File "/Applications/Positron.app/Contents/Resources/app/extensions/positron-python/python_files/positron/positron_language_server.py", line 12, in [Python] from positron_ipykernel.positron_ipkernel import PositronIPKernelApp [Python] File "/Applications/Positron.app/Contents/Resources/app/extensions/positron-python/python_files/positron/positron_ipykernel/positron_ipkernel.py", line 18, in [Python] from ipykernel.comm.manager import CommManager [Python] File "/opt/homebrew/lib/python3.12/site-packages/ipykernel/comm/__init__.py", line 3, in [Python] from .comm import Comm [Python] File "/opt/homebrew/lib/python3.12/site-packages/ipykernel/comm/comm.py", line 15, in [Python] from ipykernel.kernelbase import Kernel [Python] File "/opt/homebrew/lib/python3.12/site-packages/ipykernel/kernelbase.py", line 41, in [Python] from IPython.core.error import StdinNotImplementedError [Python] File "/opt/homebrew/lib/python3.12/site-packages/IPython/__init__.py", line 54, in [Python] from .core.application import Application [Python] File "/opt/homebrew/lib/python3.12/site-packages/IPython/core/application.py", line 26, in [Python] from IPython.core import release, crashhandler [Python] File "/opt/homebrew/lib/python3.12/site-packages/IPython/core/crashhandler.py", line 27, in [Python] from IPython.core import ultratb [Python] File "/opt/homebrew/lib/python3.12/site-packages/IPython/core/ultratb.py", line 105, in [Python] from pygments.formatters.terminal256 import Terminal256Formatter [Python] ModuleNotFoundError: No module named 'pygments' ```
seeM commented 3 months ago

Somehow this environment ended up with ipykernel and ipython installed, but no pygments:

ipykernel==6.28.0
ipython==8.20.0

Our ipykernel installation check works by testing whether import ipykernel errors. If you don't have pygments installed, import ipykernel will still succeed. I suppose we could update that to also check whether ipython is installed since import ipython does error if pygments is missing?