Skip to content

Commit 24e807c

Browse files
authored
Run Package Control settings helper in isolated mode (#308)
This commit fixes following scenario: `install_package_control.sh` adds the packages listed by name in `extra-packages` to Package Control's settings with `python3 -B -`. A script read from stdin gets the current directory at the start of `sys.path`, and that directory is usually the package checkout. So a module in the package's root that has the name of a standard library module gets imported instead of it. In sublimelsp/LSP-elm, `types.py` breaks `import json` on macOS (Homebrew Python 3.15), since `enum` imports `types`: ``` File "/Users/runner/work/LSP-elm/LSP-elm/types.py", line 3, in <module> from LSP.protocol import DocumentUri ModuleNotFoundError: No module named 'LSP' ``` Ubuntu and Windows pass, probably because their Python has already imported `types` at startup. `-I` (isolated mode) leaves the current directory and user site-packages off `sys.path` and ignores `PYTHON*` environment variables. The helper only needs the standard library. The PowerShell script doesn't run Python here.
1 parent c18f8d0 commit 24e807c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎actions/setup/install_package_control.sh‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ fi
5959
if [ -n "$UNITTESTING_PC_PACKAGES" ]; then
6060
echo Adding packages to be installed by Package Control:
6161
printf '%s' "$UNITTESTING_PC_PACKAGES" | sed 's/^/ /'
62-
python3 -B - "$STP/User/Package Control.sublime-settings" <<'EOF'
62+
# -I keeps the current directory, usually the package checkout, off sys.path, so that its modules can't shadow the
63+
# standard library, e.g. a `types.py` breaking `import json`.
64+
python3 -I -B - "$STP/User/Package Control.sublime-settings" <<'EOF'
6365
import json
6466
import os
6567
import sys

0 commit comments

Comments
 (0)