Skip to content
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

Avoid re-using old ~/.pex/code/ caches. #1444

Merged
merged 1 commit into from
Sep 10, 2021
Merged

Conversation

jsirois
Copy link
Member

@jsirois jsirois commented Sep 10, 2021

The original $PEX_ROOT/code/<code_hash> cache scheme was broken since
the <code_hash> was calculated just using user code but the contents
of the cache included Pex's __main__.py and PEX-INFO files. The
latter was luckily never loaded by the Pex runtime to figure out how to
run and so the bug never surfaced.

With the introduction of the zipapp and packed runtime layout support,
these bad cache entries are now used and the PEX-INFO is read. This
means, for the case of PEXes with no user code that were also
--not-zip-safe, all such PEXes share the PEX-INFO of the 1st such
PEX executed in a given $PEX_ROOT. This leads to unexpected
dependencies and crashes when executing any such PEX other than the
seeding PEX.

Fix this by simply re-naming the code/ cache dir root to user_code,
allowing previous PEXes to work as prior and new PEXes to also work by
completely ignoring the old buggy code/ caches.

Fixes #1443

The original `$PEX_ROOT/code/<code_hash>` cache scheme was broken since
the `<code_hash>` was calculated just using user code but the contents
of the cache included Pex's `__main__.py` and `PEX-INFO` files. The
latter was luckily never loaded by the Pex runtime to figure out how to
run and so the bug never surfaced.

With the introduction of the zipapp and packed runtime layout support,
these bad cache entries are now used and the `PEX-INFO` is read. This
means, for the case of PEXes with no user code that were also
`--not-zip-safe`, all such PEXes share the `PEX-INFO` of the 1st such
PEX executed in a given `$PEX_ROOT`. This leads to unexpected
dependencies and crashes when executing any such PEX other than the
seeding PEX.

Fix this by simply re-naming the `code/` cache dir root to `user_code`,
allowing previous PEXes to work as prior and new PEXes to also work by
completely ignoring the old buggy `code/` caches.

Fixes pex-tool#1443
@jsirois jsirois mentioned this pull request Sep 10, 2021
1 task
@jsirois jsirois merged commit 98b70f6 into pex-tool:main Sep 10, 2021
@jsirois jsirois deleted the issues/1443 branch September 10, 2021 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

_load_type_error does not handle that dist may be None
2 participants