Skip to content

🐛 fix(discovery): read $PWD when the working directory can't be named - #263

Open
hnwg wants to merge 1 commit into
tox-dev:mainfrom
hnwg:fix-active-versions-missing-cwd
Open

hnwg wants to merge 1 commit into
tox-dev:mainfrom
hnwg:fix-active-versions-missing-cwd

Conversation

@hnwg

@hnwg hnwg commented Nov 14, 2026

Copy link
Copy Markdown

Fixes #255.

Path.cwd() raises in _active_versions, and then get_interpreter fails while it resolves a pyenv shim. Delete the working directory and it's FileNotFoundError (reproduced on Linux); on illumos it's PermissionError when an ancestor can't be read (#255).

So the local lookup now starts from PWD in env, where pyenv's own search starts too (${PYENV_DIR:=$PWD} in pyenv-version-file); a local pin still beats the global version file. test_shim_unsearchable_directory_is_skipped sets PWD too now, which should make it pass on illumos.

The new test fails on main for both errors and passes here, on Ubuntu (WSL) and on Windows 11. I don't have illumos; a sitecustomize stood in for it, making os.getcwd raise EACCES below an unreadable directory: with that, the unsearchable test fails on main with the error from the issue and passes here. Not run on illumos itself or on macOS.

Resolving a pyenv shim looks for `.python-version` starting from
`Path.cwd()`. That raises when the working directory was removed
(FileNotFoundError) or, on illumos, when an ancestor can't be read
(PermissionError), so `get_interpreter` failed (tox-dev#255).

Fall back to `PWD` from the environment, pyenv's default start for its
own `.python-version` search, so a local pin still wins over the global
version. The unsearchable directory test now sets `PWD`, so it also
passes where getcwd fails.

This branch has not been deployed

No deployments
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.

[illumos] test_shim_unsearchable_directory_is_skipped fails with Permission denied

1 participant