Repository navigation
Stop the Python extension from writing files into the app bundle - #16581
Open
juliasilge wants to merge 1 commit into
Open
juliasilge wants to merge 1 commit into
juliasilge wants to merge 1 commit into
Conversation
|
E2E Tests 🚀 Why these tags?
More on automatic tags from changed files. |
Member
Author
|
Here are some macOS builds to check: https://github.com/posit-dev/positron-builds/actions/runs/37990650712 |
juliasilge
marked this pull request as ready for review
October 9, 2026 21:47
|
Tip This PR moves the Python terminal deactivate scripts to global storage and stops bytecode writes, so Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12281
What used to happen
The issue was first reported on 2026.03.0, quite a while ago. After the first launch,
codesign --verify --deep --stricton Positron.app failed with "a sealed resource is missing or invalid". At that time, the extra files came from the Copilot extension. It copiedrg,pty.node, andspawn-helperinto itsnode_modulesfolder at runtime.An upstream change removed the Copilot part. Built-in installs now ship a
shims.txtplaceholder, and Copilot does not copy these files when that placeholder is present. On 2026.11.0-17, the Copilot files no longer appear.However, the signature was still not valid on 2026.11.0-17, because the Python extension wrote 26 files into the bundle:
python_files/deactivate/zsh/envVars.txt: the terminal deactivate service wrote this file on each launch. The service starts a hidden terminal and writes the shell environment (PATH,PS1) to a file next to thedeactivatescript. That script is in the extension folder, inside the app bundle..pycfiles inpython_files/lib/python/{packaging,tomli,importlib_metadata}/__pycache__:installed_check.pyimports these libraries when you open arequirements.txtorpyproject.tomlfile. Python wrote their bytecode next to the source files.I believe that a changed bundle can cause problems on managed Macs that check the signature again. On read-only installs (a root-owned
/Applications, Linux packages, Windows system installs), theenvVars.txtwrite failed. Then thedeactivatecommand in venv terminals did not work, and the service waited 30 seconds for the file.I also started a Python console, ran code, and quit. The kernel did not add files to the bundle.
How this PR fixes it
globalStorageUri/deactivate/<shell>instead of the extension folder. Before it writesenvVars.txt, it copies the shippeddeactivate(ordeactivate.ps1) script to that folder. The scripts readenvVars.txtfrom their own folder, so they did not need changes. The folder that the service adds to the terminalPATHis now the storage folder.installed_check.pynow runs withPYTHONDONTWRITEBYTECODE=1.Both files are upstream vscode-python files, so the changes are inside Positron fences.
Release Notes
New Features
Bug Fixes
Validation Steps
@:interpreter @:win
Unit tests cover the new storage location and the environment variable for
installed_check.py.To do a manual test on macOS with a release build:
/Applications. Make sure thatcodesign --verify --deep --strict --verbose=2 /Applications/Positron.appshows no errors.requirements.txtorpyproject.tomlfile.deactivate. The command must work as before.codesigncommand again. It must not show "file added" lines.