Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 15, 2025

Poetry environments in cache directories were reported as kind = 'Venv' instead of 'Poetry' when workspace directories weren't configured or pyproject.toml wasn't in the workspace.

Example:

Path: /Users/user/Library/Caches/pypoetry/virtualenvs/nestedpoetry-yJwtIF_Q-py3.11/
Before: kind = 'Venv'
After:  kind = 'Poetry'

Changes

Root cause: Poetry::try_from() only checked cached environments from find(). Uncached environments returned None, falling through to Venv locator.

Solution: Added fallback path-based detection when cache lookup fails:

fn is_poetry_environment(path: &Path) -> bool {
    // Check path contains "pypoetry/virtualenvs"
    // Validate directory name matches: {name}-{8-char-hash}-py{version}
    // Regex: ^.+-[A-Za-z0-9_-]{8}-py.*$
}

Updated try_from() to check path pattern after cache miss, creating Poetry environment if pattern matches. Works across platforms (macOS, Linux, Windows) without filesystem I/O.

Testing

Added 8 unit tests covering:

  • Platform-specific paths (macOS/Linux/Windows cache directories)
  • Pattern variations (with/without version suffix)
  • Negative cases (non-Poetry paths, wrong hash length)
  • Real-world examples from bug report
Original prompt

This section details on the original issue you should resolve

<issue_title>Bug: Poetry path returned as type "venv"</issue_title>
<issue_description>you can see from the path it is in the poetry folder but the type comes back as venv instead

Image</issue_description>

<agent_instructions>The issue is that poetry envs sometimes get reported as venvs.
Analyse and perform root causes analysis before attempting to fix this issue.
Once you have determine the root cause use that information to create tests and then try to fix the issue and verify whether the tests pass.
</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 15, 2025 07:26
- Add is_poetry_environment() helper to detect Poetry envs by path pattern
- Update try_from() to use path pattern as fallback when env not in cache
- Add comprehensive unit tests for path pattern matching
- Fixes issue where Poetry environments are incorrectly identified as Venv

Co-authored-by: DonJayamanne <1948812+DonJayamanne@users.noreply.github.com>
Co-authored-by: DonJayamanne <1948812+DonJayamanne@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix poetry environment type reporting issue Fix Poetry environments misidentified as Venv Nov 15, 2025
Copilot AI requested a review from DonJayamanne November 15, 2025 07:35
Copilot finished work on behalf of DonJayamanne November 15, 2025 07:35
@DonJayamanne DonJayamanne marked this pull request as ready for review November 15, 2025 13:56
@DonJayamanne DonJayamanne marked this pull request as draft November 15, 2025 13:57
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.

Bug: Poetry path returned as type "venv"

2 participants