vscode-jupyter: Jupyter extension breaks code folding in ordinary python files

Environment data

  • VS Code version: 1.72.0, 64bbfbf67ada9953918d72e1df2f4d8e537d340e, x64
  • Jupyter Extension version: v2022.9.1002671058 and later are broken, v2022.9.1002661205 and earlier are fine; I bisected to this having found that v2022.8.1002431955 worked but the upgrade to 2022.9.1002791758 broke things
  • Python Extension version: v2022.16.0
  • OS and version: Ubuntu 20.04.5 LTS
  • Python version: at least Python 3.7 and 3.9 from deadsnakes, other versions untested
  • Type of virtual environment used: virtualenv, via virtualenvwrapper
  • Jupyter server running: none

Expected behaviour

Code folding in ordinary Python files should work. Historically it has worked based on indent levels.

Actual behaviour

Code folding does not work. No folding regions are detected, though regions which were folded in the previous session remain usable. Keyboard shortcuts for collapsing to a given “level” of folding do not work (nothing happens).

Steps to reproduce:

  1. $ workon <env name>
  2. $ code .
  3. open a python file (in my case I have files which auto-opened as they were open in a previous session)
  4. try to fold code, either by hovering over the sidebar or via keyboard shortcut

Note that I have not opened a Jupyter notebook in this workspace, either in this session or otherwise.

Logs

v2022.9.1002671058
Visual Studio Code (1.72.0, undefined, desktop)
Jupyter Extension Version: 2022.9.1002671058.
Python Extension Version: 2022.16.0.
Workspace folder /home/srobo/competition-simulator
error 16:48:23.860: Exception while attempting zmq : [Error: /snap/core/current/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/node_modules/zeromq/prebuilds/linux-x64/electron.napi.glibc.node)
	at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1812)
	at Module._extensions..node (node:internal/modules/cjs/loader:1250:18)
	at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1812)
	at Module.load (node:internal/modules/cjs/loader:1035:32)
	at Module._load (node:internal/modules/cjs/loader:876:12)
	at c._load (node:electron/js2c/asar_bundle:5:13343)
	at r._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:116:14565)
	at v._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:65015)
	at E._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:64383)
	at Module.require (node:internal/modules/cjs/loader:1059:19)
	at p (/snap/code/109/usr/share/code/resources/app/out/vs/loader.js:4:699)
	at load (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/node_modules/node-gyp-build/index.js:1:628)
	at Object.<anonymous> (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/node_modules/zeromq/lib/native.js:1:198)
	at u._compile (/snap/code/109/usr/share/code/resources/app/out/vs/loader.js:4:1313)
	at Module._extensions..js (node:internal/modules/cjs/loader:1220:10)
	at Module.load (node:internal/modules/cjs/loader:1035:32)
	at Module._load (node:internal/modules/cjs/loader:876:12)
	at c._load (node:electron/js2c/asar_bundle:5:13343)
	at r._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:116:14565)
	at v._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:65015)
	at E._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:64383)
	at Module.require (node:internal/modules/cjs/loader:1059:19)
	at p (/snap/code/109/usr/share/code/resources/app/out/vs/loader.js:4:699)
	at Object.<anonymous> (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/node_modules/zeromq/lib/index.js:1:144)
	at u._compile (/snap/code/109/usr/share/code/resources/app/out/vs/loader.js:4:1313)
	at Module._extensions..js (node:internal/modules/cjs/loader:1220:10)
	at Module.load (node:internal/modules/cjs/loader:1035:32)
	at Module._load (node:internal/modules/cjs/loader:876:12)
	at c._load (node:electron/js2c/asar_bundle:5:13343)
	at r._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:116:14565)
	at v._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:65015)
	at E._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:64383)
	at Module.require (node:internal/modules/cjs/loader:1059:19)
	at p (/snap/code/109/usr/share/code/resources/app/out/vs/loader.js:4:699)
	at 92747 (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/extension.node.js:17:594988)
	at __webpack_require__ (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/extension.node.js:17:1479355)
	at l.zmqSupported (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/extension.node.js:2:2217651)
	at l.isSupportedForLocalLaunch (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/extension.node.js:2:2217394)
	at get isSupported [as isSupported] (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/extension.node.js:2:2217304)
	at t.registerTypes (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/extension.node.js:2:2232316)
	at /home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/extension.node.js:2:1640908
	at /home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/extension.node.js:2:1641663
	at /home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/extension.node.js:2:1641671
	at t.activate (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002671058/out/extension.node.js:2:1641793)
	at Fn._callActivateOptional (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:17678)
	at Fn._callActivate (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:17338)
	at /snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:15133
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async E._activate (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:88:8191)
	at async E._waitForDepsThenActivate (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:88:8133)
	at async E._initialize (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:88:7497)] {
  code: 'ERR_DLOPEN_FAILED'
}
User belongs to experiment group 'jupyterTest'
User belongs to experiment group 'jupyterEnhancedDataViewer'
info 16:48:24.104: LSP Notebooks experiment is disabled -- not using Pylance
info 16:48:24.202: Got env vars ourselves faster /home/peter/.virtualenvs/competition-simulator/bin/python with env var count 97 in 61ms
info 16:48:24.202: Got env vars ourselves faster /home/peter/.virtualenvs/competition-simulator/bin/python with env var count 97 in 60ms
info 16:48:24.202: Got env vars ourselves faster /home/peter/.virtualenvs/competition-simulator/bin/python with env var count 97 in 60ms
info 16:48:24.211: Process Execution: > ~/.virtualenvs/competition-simulator/bin/python -m pip list
> ~/.virtualenvs/competition-simulator/bin/python -m pip list
info 16:48:24.218: Process Execution: > ~/.virtualenvs/competition-simulator/bin/python -c "import jupyter"
> ~/.virtualenvs/competition-simulator/bin/python -c "import jupyter"
info 16:48:24.226: Process Execution: > ~/.virtualenvs/competition-simulator/bin/python -c "import notebook"
> ~/.virtualenvs/competition-simulator/bin/python -c "import notebook"
info 16:48:24.441: Got env vars with python /home/peter/.virtualenvs/competition-simulator/bin/python, with env var count 97 and custom env var count 0 in 299ms
info 16:48:24.442: Got env vars with python /home/peter/.virtualenvs/competition-simulator/bin/python, with env var count 97 and custom env var count 0 in 300ms
info 16:48:24.442: Got env vars with python /home/peter/.virtualenvs/competition-simulator/bin/python, with env var count 97 and custom env var count 0 in 301ms
v2022.9.1002661205
Visual Studio Code (1.72.0, undefined, desktop)
Jupyter Extension Version: 2022.9.1002661205.
Python Extension Version: 2022.16.0.
Workspace folder /home/srobo/competition-simulator
error 16:49:58.247: Exception while attempting zmq : [Error: /snap/core/current/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/node_modules/zeromq/prebuilds/linux-x64/electron.napi.glibc.node)
	at process.func [as dlopen] (node:electron/js2c/asar_bundle:5:1812)
	at Module._extensions..node (node:internal/modules/cjs/loader:1250:18)
	at Object.func [as .node] (node:electron/js2c/asar_bundle:5:1812)
	at Module.load (node:internal/modules/cjs/loader:1035:32)
	at Module._load (node:internal/modules/cjs/loader:876:12)
	at c._load (node:electron/js2c/asar_bundle:5:13343)
	at r._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:116:14565)
	at v._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:65015)
	at E._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:64383)
	at Module.require (node:internal/modules/cjs/loader:1059:19)
	at p (/snap/code/109/usr/share/code/resources/app/out/vs/loader.js:4:699)
	at load (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/node_modules/node-gyp-build/index.js:1:628)
	at Object.<anonymous> (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/node_modules/zeromq/lib/native.js:1:198)
	at u._compile (/snap/code/109/usr/share/code/resources/app/out/vs/loader.js:4:1313)
	at Module._extensions..js (node:internal/modules/cjs/loader:1220:10)
	at Module.load (node:internal/modules/cjs/loader:1035:32)
	at Module._load (node:internal/modules/cjs/loader:876:12)
	at c._load (node:electron/js2c/asar_bundle:5:13343)
	at r._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:116:14565)
	at v._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:65015)
	at E._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:64383)
	at Module.require (node:internal/modules/cjs/loader:1059:19)
	at p (/snap/code/109/usr/share/code/resources/app/out/vs/loader.js:4:699)
	at Object.<anonymous> (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/node_modules/zeromq/lib/index.js:1:144)
	at u._compile (/snap/code/109/usr/share/code/resources/app/out/vs/loader.js:4:1313)
	at Module._extensions..js (node:internal/modules/cjs/loader:1220:10)
	at Module.load (node:internal/modules/cjs/loader:1035:32)
	at Module._load (node:internal/modules/cjs/loader:876:12)
	at c._load (node:electron/js2c/asar_bundle:5:13343)
	at r._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:116:14565)
	at v._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:65015)
	at E._load (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:111:64383)
	at Module.require (node:internal/modules/cjs/loader:1059:19)
	at p (/snap/code/109/usr/share/code/resources/app/out/vs/loader.js:4:699)
	at 92747 (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/extension.node.js:17:594988)
	at __webpack_require__ (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/extension.node.js:17:1479039)
	at l.zmqSupported (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/extension.node.js:2:2209302)
	at l.isSupportedForLocalLaunch (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/extension.node.js:2:2209045)
	at get isSupported [as isSupported] (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/extension.node.js:2:2208955)
	at t.registerTypes (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/extension.node.js:2:2223967)
	at /home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/extension.node.js:2:1640908
	at /home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/extension.node.js:2:1641663
	at /home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/extension.node.js:2:1641671
	at t.activate (/home/peter/.vscode/extensions/ms-toolsai.jupyter-2022.9.1002661205/out/extension.node.js:2:1641793)
	at Fn._callActivateOptional (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:17678)
	at Fn._callActivate (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:17338)
	at /snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:102:15133
	at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
	at async E._activate (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:88:8191)
	at async E._waitForDepsThenActivate (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:88:8133)
	at async E._initialize (/snap/code/109/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:88:7497)] {
  code: 'ERR_DLOPEN_FAILED'
}
User belongs to experiment group 'jupyterTest'
User belongs to experiment group 'jupyterEnhancedDataViewer'
info 16:49:58.476: LSP Notebooks experiment is disabled -- not using Pylance
info 16:49:58.643: Got env vars ourselves faster /home/peter/.virtualenvs/competition-simulator/bin/python with env var count 97 in 111ms
info 16:49:58.643: Got env vars ourselves faster /home/peter/.virtualenvs/competition-simulator/bin/python with env var count 97 in 111ms
info 16:49:58.643: Got env vars ourselves faster /home/peter/.virtualenvs/competition-simulator/bin/python with env var count 97 in 110ms
info 16:49:58.652: Process Execution: > ~/.virtualenvs/competition-simulator/bin/python -m pip list
> ~/.virtualenvs/competition-simulator/bin/python -m pip list
info 16:49:58.659: Process Execution: > ~/.virtualenvs/competition-simulator/bin/python -c "import jupyter"
> ~/.virtualenvs/competition-simulator/bin/python -c "import jupyter"
info 16:49:58.667: Process Execution: > ~/.virtualenvs/competition-simulator/bin/python -c "import notebook"
> ~/.virtualenvs/competition-simulator/bin/python -c "import notebook"
info 16:49:58.858: Got env vars with python /home/peter/.virtualenvs/competition-simulator/bin/python, with env var count 97 and custom env var count 0 in 326ms
info 16:49:58.894: Got env vars with python /home/peter/.virtualenvs/competition-simulator/bin/python, with env var count 97 and custom env var count 0 in 361ms
info 16:49:58.895: Got env vars with python /home/peter/.virtualenvs/competition-simulator/bin/python, with env var count 97 and custom env var count 0 in 362ms
$ code --list-extensions
alefragnani.Bookmarks
bbenoist.vagrant
coolbear.systemd-unit-file
DavidAnson.vscode-markdownlint
dbaeumer.vscode-eslint
eamodio.gitlens
EditorConfig.EditorConfig
edonet.vscode-command-runner
esbenp.prettier-vscode
lextudio.restructuredtext
ms-python.python
ms-python.vscode-pylance
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-toolsai.vscode-jupyter-cell-tags
ms-toolsai.vscode-jupyter-slideshow
ms-vsliveshare.vsliveshare
PeterJCLaw.tuck
puppet.puppet-vscode
rust-lang.rust-analyzer
stkb.rewrap
streetsidesoftware.code-spell-checker
swyphcosmo.spellchecker
william-voyek.vscode-nginx
wmaurer.change-case

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 6
  • Comments: 16 (6 by maintainers)

Most upvoted comments

ok, looks like that is the reason then, and the python extension ran into the same problem 4 years ago - https://github.com/Microsoft/vscode/issues/50991

To workaround, you can add either of these settings: "jupyter.pythonCellFolding": false or "editor.foldingStrategy": "indentation".

To have both cell folding and indentation folding, pylance needs to be used as the language server so that the python extension provides folding regions. We may just end up disabling cell folding by default to avoid this situation.

It seems that "jupyter.pythonCellFolding": false is deprecated?

Using "editor.foldingStrategy": "indentation", in settings.json resulted in

  1. .py file image

  2. .ipynb file image

Is is possible for VSCode to support double folding strategy to support both # %% and indent at the same time?

Supremely annoying - I’ve resorted to disabling Jupyter, folding sections of code I’m not working on, and then re-enabling Jupyter.